GeezerVison is showing github.com — 'NoneType' is not iterable when running a Docker hook · Issue #3514 · pre-commit/pre-commit
'NoneType' is not iterable when running a Docker hook #3514Descriptionsearch 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
Activityasottile commented on Aug 19, 2025 can you show the output of 'docker' 'system' 'info' '--format' '{{ json . }}' jenstroeger commented on 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 commented on Aug 20, 2025 you can redact most of it I'm mostly interested in the bits near SecurityOptions if present jenstroeger commented on Aug 20, 2025 Two points I’d like to make. One, here’s the information you asked for and SecurityOptions actually does exist:
> docker system info --format json | jq
{
"ID": "fb62e55a-749a-40c7-9828-a7407756f5d7",
"Containers": 2,
"ContainersRunning": 0,
"ContainersPaused": 0,
"ContainersStopped": 2,
"Images": 42,
"Driver": "overlay2",
"DriverStatus": [
...
"SecurityOptions": [
"name=seccomp,profile=builtin",
"name=cgroupns"
],
...
Two, Docker failed in all sorts of ways after the update I mentioned above so I restarted it. Now pre-commit works ok. Still, the failing
|
# docker: |
|
# https://docs.docker.com/reference/api/engine/version/v1.48/#tag/System/operation/SystemInfo |
|
'name=rootless' in info.get('SecurityOptions', ()) or |
could be a
info.get('SecurityOptions') or ()
just to be on the safe side? asottile commented on Aug 20, 2025 as far as I can tell it should never have "SecurityOptions": null and it looks like your output has a valid "SecurityOptions" now so unfortunately no reproduction :( jenstroeger commented on 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 commented on Aug 20, 2025 jenstroeger commented on Aug 21, 2025 Ok, I just updated Docker again and first thing I did was:
> docker system info --format json | jq '.["SecurityOptions"]'
[
"name=seccomp,profile=builtin",
"name=cgroupns"
]
The Docker pre-commit hook worked immediately as well. I’ll keep an eye out in case this happens again. jenstroeger commented on Sep 1, 2025 Interesting! I was just noodling along when Docker decided to stop working. So here we go:
> docker system info --format json | jq '.["SecurityOptions"]'
request returned 500 Internal Server Error for API route and version http://%2FUsers%2Fjens%2F.docker%2Frun%2Fdocker.sock/v1.51/info, check if the server supports the requested API version
null
I also kept the entire system info if you need it, which indeed contains
{
...
"SecurityOptions":null,
...
}
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:
> docker system info --format json | jq '.["SecurityOptions"]'
Cannot connect to the Docker daemon at unix:///Users/jens/.docker/run/docker.sock. Is the docker daemon running?
null
asottile commented on 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
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|