Repository navigation
'NoneType' is not iterable when running a Docker hook #3514
Copy link
Copy link
Closed
Description
search you tried in the issue tracker
"not iterable", "Docker None"
describe your issue
This started happening after I updated pre-commit and Docker:
ShellCheck v0.11.0.......................................................An unexpected error has occurred: TypeError: argument of type 'NoneType' is not iterable
Check the log at /Users/jens/.cache/pre-commit/pre-commit.log
make: *** [Makefile:241: check] Error 3
With pre-commit v4.2.0 I now get
ShellCheck v0.11.0.......................................................Failed
- hook id: shellcheck
- exit code: 125
docker: request returned 500 Internal Server Error for API route and version http://%2FUsers%2Fjens%2F.docker%2Frun%2Fdocker.sock/_ping, check if the server supports the requested API version
which wasn’t the case previously. This is for
> docker --version
Docker version 28.3.2, build 578ccf6
but I’ve not tried an older version of Docker yet.
pre-commit --version
pre-commit 4.3.0
.pre-commit-config.yaml
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.11.0
hooks:
- id: shellcheck
args: [--severity=warning]~/.cache/pre-commit/pre-commit.log (if present)
version information
pre-commit version: 4.3.0
git --version: git version 2.50.1
sys.version:
3.13.6 (main, Aug 9 2025, 06:37:32) [Clang 14.0.3 (clang-1403.0.22.14.1)]
sys.executable: /path/to/.venv/bin/python
os.name: posix
sys.platform: darwin
error information
An unexpected error has occurred: TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/main.py", line 417, in main
return run(args.config, store, args)
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/commands/run.py", line 444, in run
return _run_hooks(config, hooks, skips, args)
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/commands/run.py", line 296, in _run_hooks
current_retval, prior_diff = _run_single_hook(
~~~~~~~~~~~~~~~~^
classifier, hook, skips, cols, prior_diff,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verbose=args.verbose, use_color=args.color,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/commands/run.py", line 193, in _run_single_hook
retcode, out = language.run_hook(
~~~~~~~~~~~~~~~~~^
hook.prefix,
^^^^^^^^^^^^
...<5 lines>...
color=use_color,
^^^^^^^^^^^^^^^^
)
^
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/languages/docker_image.py", line 26, in run_hook
cmd = docker_cmd(color=color) + lang_base.hook_cmd(entry, args)
~~~~~~~~~~^^^^^^^^^^^^^
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/languages/docker.py", line 146, in docker_cmd
*get_docker_user(),
~~~~~~~~~~~~~~~^^
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/languages/docker.py", line 128, in get_docker_user
if _is_rootless():
~~~~~~~~~~~~^^
File "/path/to/.venv/lib/python3.13/site-packages/pre_commit/languages/docker.py", line 118, in _is_rootless
'name=rootless' in info.get('SecurityOptions', ()) or
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
Metadata
Metadata
Assignees
Labels
No labels
Activity
asottile commentedon Aug 19, 2025
can you show the output of
'docker' 'system' 'info' '--format' '{{ json . }}'jenstroeger commentedon Aug 19, 2025
There’s a bunch of private information there as well, do you have an email address I can send it to (instead of posting it here to the world)?
asottile commentedon Aug 20, 2025
you can redact most of it I'm mostly interested in the bits near
SecurityOptionsif presentjenstroeger commentedon Aug 20, 2025
Two points I’d like to make. One, here’s the information you asked for and
SecurityOptionsactually does exist:Two, Docker failed in all sorts of ways after the update I mentioned above so I restarted it. Now
pre-commitworks ok. Still, the failingpre-commit/pre_commit/languages/docker.py
Lines 116 to 118 in e70b313
just to be on the safe side?
asottile commentedon Aug 20, 2025
as far as I can tell it should never have
"SecurityOptions": nulland it looks like your output has a valid "SecurityOptions" now so unfortunately no reproduction :(jenstroeger commentedon Aug 20, 2025
Agree, and I’ve not had problems with updating Docker before. Perhaps we close this issue for now and in case this happens again we know what’s helpful to reproduce it.
asottile commentedon Aug 20, 2025
sg2m!
jenstroeger commentedon Aug 21, 2025
Ok, I just updated Docker again and first thing I did was:
The Docker pre-commit hook worked immediately as well. I’ll keep an eye out in case this happens again.
jenstroeger commentedon Sep 1, 2025
Interesting! I was just noodling along when Docker decided to stop working. So here we go:
I also kept the entire system info if you need it, which indeed contains
Have to restart Docker soon, though, because I’m blocked. But it turns out you can get the same result by just quitting Docker and then:
asottile commentedon Sep 6, 2025
neat. quite surprising but neat. I assume docker was completely broken at that point but probably better for pre-commit to try a bit more so it at least points to docker being broken
build(deps): update pre-commit to v4.4.0