mrocklin: Thanks for the fix @bolliger32 !  

Do you have any thoughts on what a small test would be for this change?  It would be good to have such a test to make sure that your work doesn't get reverted in the future by some careless change.
bolliger32: Ah good call! Will think something up and push it. Thanks for working w/ a first-timer.
bolliger32: ok @mrocklin just needed a tiny change to an existing test and I think we're good.
diff --git a/dask/config.py b/dask/config.py
index 3785e6f98..918e1cb92 100644
--- a/dask/config.py
+++ b/dask/config.py
@@ -448,7 +448,7 @@ def rename(aliases, config=config):
             new[n] = value
 
     for k in old:
-        del config[k]  # TODO: support nested keys
+        del config[canonical_name(k, config)]  # TODO: support nested keys
 
     set(new, config=config)
 

keyerror in dask.config.rename when working with distributed
calling `dask-worker` using `dask==1.2.2`, `distributed==1.28.1`, I get the following error:

`Traceback (most recent call last): File "/opt/conda/envs/worker/bin/dask-worker", line 7, in <module> from distributed.cli.dask_worker import go File "/opt/conda/envs/worker/lib/python3.6/site-packages/distributed/__init__.py", line 3, in <module> from . import config File "/opt/conda/envs/worker/lib/python3.6/site-packages/distributed/config.py", line 55, in <module> dask.config.rename(aliases) File "/opt/conda/envs/worker/lib/python3.6/site-packages/dask/config.py", line 451, in rename del config[k] # TODO: support nested keys KeyError: 'tick-maximum-delay'`

It looks like this was introduced by #4742 when `dask.config.rename` was not properly adjusted, so that it can run into these KeyErrors. Current state of the function:

```def rename(aliases, config=config):
    """ Rename old keys to new keys
    This helps migrate older configuration versions over time
    """
    old = []
    new = {}
    for o, n in aliases.items():
        value = get(o, None, config=config)
        if value is not None:
            old.append(o)
            new[n] = value

    for k in old:
        del config[k]  # TODO: support nested keys

    set(new, config=config)
```

Suggest changing the 3rd to last line to `del config[canonical_name(k, config)]`. Will file an appropriate PR.
diff --git a/dask/tests/test_config.py b/dask/tests/test_config.py
index 1f6f4f891..a5d7a33d0 100644
--- a/dask/tests/test_config.py
+++ b/dask/tests/test_config.py
@@ -318,7 +318,7 @@ def test_ensure_file_defaults_to_DASK_CONFIG_directory(tmpdir):
 
 
 def test_rename():
-    aliases = {'foo-bar': 'foo.bar'}
+    aliases = {'foo_bar': 'foo.bar'}
     config = {'foo-bar': 123}
     rename(aliases, config=config)
     assert config == {'foo': {'bar': 123}}

pip install -e .[complete]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
click==8.0.4
cloudpickle==2.2.1
coverage==6.2
-e git+https://github.com/dask/dask.git@30363187bfab64629e8eff3495854554b5742d69#egg=dask
distributed==1.28.1
execnet==1.9.0
HeapDict==1.0.1
importlib-metadata==4.8.3
iniconfig==1.1.1
locket==1.0.0
msgpack==1.0.5
numpy==1.19.5
packaging==21.3
pandas==1.1.5
partd==1.2.0
pluggy==1.0.0
psutil==7.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-asyncio==0.16.0
pytest-cov==4.0.0
pytest-mock==3.6.1
pytest-xdist==3.0.2
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.1
six==1.17.0
sortedcontainers==2.4.0
tblib==1.7.0
tomli==1.2.3
toolz==0.12.0
tornado==6.1
typing_extensions==4.1.1
zict==2.1.0
zipp==3.6.0

name: dask
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - click==8.0.4
      - cloudpickle==2.2.1
      - coverage==6.2
      - distributed==1.28.1
      - execnet==1.9.0
      - heapdict==1.0.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - locket==1.0.0
      - msgpack==1.0.5
      - numpy==1.19.5
      - packaging==21.3
      - pandas==1.1.5
      - partd==1.2.0
      - pluggy==1.0.0
      - psutil==7.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-asyncio==0.16.0
      - pytest-cov==4.0.0
      - pytest-mock==3.6.1
      - pytest-xdist==3.0.2
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.1
      - six==1.17.0
      - sortedcontainers==2.4.0
      - tblib==1.7.0
      - tomli==1.2.3
      - toolz==0.12.0
      - tornado==6.1
      - typing-extensions==4.1.1
      - zict==2.1.0
      - zipp==3.6.0
prefix: /opt/conda/envs/dask

dask/tests/test_config.py::test_rename
dask/tests/test_config.py::test_collect_yaml_permission_errors[directory] dask/tests/test_config.py::test_collect_yaml_permission_errors[file]
dask/tests/test_config.py::test_canonical_name dask/tests/test_config.py::test_update dask/tests/test_config.py::test_merge dask/tests/test_config.py::test_collect_yaml_paths dask/tests/test_config.py::test_collect_yaml_dir dask/tests/test_config.py::test_env dask/tests/test_config.py::test_collect dask/tests/test_config.py::test_collect_env_none dask/tests/test_config.py::test_get dask/tests/test_config.py::test_ensure_file dask/tests/test_config.py::test_set dask/tests/test_config.py::test_set_nested dask/tests/test_config.py::test_set_hard_to_copyables dask/tests/test_config.py::test_ensure_file_directory[True] dask/tests/test_config.py::test_ensure_file_directory[False] dask/tests/test_config.py::test_ensure_file_defaults_to_DASK_CONFIG_directory dask/tests/test_config.py::test_refresh dask/tests/test_config.py::test_expand_environment_variables[1-10] dask/tests/test_config.py::test_expand_environment_variables[1-11] dask/tests/test_config.py::test_expand_environment_variables[$FOO-foo] dask/tests/test_config.py::test_expand_environment_variables[inp3-out3] dask/tests/test_config.py::test_expand_environment_variables[inp4-out4] dask/tests/test_config.py::test_expand_environment_variables[inp5-out5] dask/tests/test_config.py::test_expand_environment_variables[inp6-out6] dask/tests/test_config.py::test_expand_environment_variables[inp7-out7] dask/tests/test_config.py::test_env_var_canonical_name dask/tests/test_config.py::test_get_set_canonical_name dask/tests/test_config.py::test_get_set_roundtrip[custom_key] dask/tests/test_config.py::test_get_set_roundtrip[custom-key] dask/tests/test_config.py::test_merge_None_to_dict dask/tests/test_config.py::test_core_file
dask/config.py
dask/config.py