Repository navigation
chore(devcontainer): allow pypi for pre-commit hook bootstrap - #250
Conversation
Add pypi.org and files.pythonhosted.org to the firewall's CRITICAL_DOMAINS so pre-commit can install the Python hook envs it needs on first run. Without this, `pip install .` inside the cached `pre-commit-hooks` clone fails trying to fetch PEP 517 build deps (`setuptools>=40.8.0`) plus the hook's declared runtime deps (`ruamel.yaml`, `tomli`), and the `pre-commit-hooks` environment never initializes — blocking every commit that would otherwise pass the local cargo hooks. Classifying as CRITICAL (abort-on-DNS-failure) matches `crates.io` and `registry.npmjs.org`: package-index unavailability should fail loudly at container boot, not silently break commits later. Takes effect on next devcontainer rebuild (the running container uses the image-baked copy at /usr/local/bin/init-firewall.sh). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request adds pypi.org and files.pythonhosted.org to the CRITICAL_DOMAINS list in the firewall initialization script to allow pre-commit to bootstrap Python environments. A review comment suggests updating the script's verification loop to include reachability checks for these new domains, ensuring the firewall configuration is correctly applied.
| "pypi.org" | ||
| "files.pythonhosted.org" |
There was a problem hiding this comment.
When adding new domains to CRITICAL_DOMAINS, it is recommended to also update the verification loop at the end of the script (lines 236-244) to include a reachability check for these services. This ensures that the firewall rules are correctly applied and that the package indices are actually accessible before the initialization script completes. For example, you could add a PyPI metadata URL like https://pypi.org/pypi/pip/json to the verify_url list.
Summary
Add
pypi.organdfiles.pythonhosted.orgto the devcontainer firewall'sCRITICAL_DOMAINSso pre-commit can install the Python hook envs it needs on first run.Why
The
.pre-commit-config.yamlincludes the upstreampre-commit/pre-commit-hooksrepo (Python). pre-commit clones that repo (github.com — already allowed) and then runspip install .inside the clone to build the hook environment. pip needs two sets of packages from PyPI:setuptools>=40.8.0, which pip fetches into an isolated build env before compiling the wheel.setup.cfg—ruamel.yaml>=0.15,tomli>=1.1.0for Python < 3.11.Both come from
pypi.organdfiles.pythonhosted.org. Neither host was in the allowlist, so the very firstpre-commit runaborted with:…and every subsequent commit failed the same way. The local cargo hooks (
cargo fmt,cargo clippy,cargo deny) were unaffected because they don't need any bootstrap.markdownlint-cliis Node-based and already works viaregistry.npmjs.org(allowlisted), but pre-commit processes hooks sequentially and aborted on the first Python failure before reaching it.Why CRITICAL and not OPTIONAL
Matches
crates.ioandregistry.npmjs.org: package-index unavailability should fail loudly at container boot rather than silently break every commit later.Rollout
Takes effect on the next devcontainer rebuild. Running containers keep using the image-baked copy at
/usr/local/bin/init-firewall.sh(Dockerfile line 100). No runtime migration path.Test plan
pre-commit run --all-filescompletes without thesetuptoolserrorgit commitin the container passes hooks without--no-verify🤖 Generated with Claude Code