fix(docker): install slowapi in Dockerfile.production so the image starts - #1212
fix(docker): install slowapi in Dockerfile.production so the image starts#1212groupthinking wants to merge 1 commit into
Conversation
…arts
src/youtube_extension/main.py imports slowapi unconditionally at module
top level (Limiter, SlowAPIMiddleware, rate-limit handler) and binds it at
import time. The production image's CMD is youtube_extension.main:app, but
the pip install list omitted slowapi (requirements.txt is copied, not
installed), so every container built from this file exited immediately at
startup with:
ModuleNotFoundError: No module named 'slowapi'
slowapi>=0.1.8 is a canonical dependency in both requirements.txt and
pyproject.toml; the added floor matches. This is the same 'image never
verified to start' defect class as the earlier server:app CMD fix, one
import deeper — flagged by Vercel VADE review on #1122 and #1128 and
independently verified, then shipped to main when #1128 merged.
The existing floor guard did not catch this because it only validates
packages already present in the install list, never asserting that every
canonical runtime import resolves to an installed pin.
Verified: tests/unit/test_security_fixes.py Dockerfile guards — 5 passed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6KJmeCL8QnxYEKuVimf9J
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CI triage for this one-line fix — functional checks pass; the reds are all pre-existing/governance, none caused by this change: Passing: Red — not fixable in this PR:
Fixed this round: added the Net: the code change is minimal, correct, and verified. Terminal state is Generated by Claude Code |
Agent Completion Truth Gate: BLOCKEDReasons: Machine-readable verdict{
"details": {
"invalid_fields": [
"issue.number",
"policy.agent_login",
"policy.run_id"
]
},
"reasons": [
"invalid_payload"
],
"verdict": "blocked"
} |
|
Closing as a duplicate of canonical focused repair #1121 / PR #1122. The verified |
|
Agreed — closing as a duplicate is the right call, and #1122 is the better home: it pairs the One factual note tied to why this was escalated: the crash is live on Generated by Claude Code |
Summary
main's production image crashes at startup withModuleNotFoundError: No module named 'slowapi'. This is a one-line fix: addslowapi>=0.1.8to theDockerfile.productioninstall list.Why it's broken on
mainsrc/youtube_extension/main.py:14-17importsslowapiunconditionally at module top level (Limiter,SlowAPIMiddleware,_rate_limit_exceeded_handler,get_remote_address) and binds it at import time (limiter = Limiter(...),app.add_middleware(SlowAPIMiddleware)).Dockerfile.production'sCMDisyoutube_extension.main:app, so uvicorn imports that module at startup →slowapimust be importable in the image.RUN pip installlist shipped 8 packages and omittedslowapi;requirements.txtis copied but deliberately not-r-installed. So the container exits immediately on boot.slowapi>=0.1.8is a canonical dependency in bothrequirements.txt:8andpyproject.toml:36; the added floor matches.This is the same "the production image was never actually verified to start" defect class the earlier
server:app→youtube_extension.main:appCMD fix addressed — one import deeper. It was flagged by Vercel VADE review on #1122 and #1128, independently verified, and shipped tomainwhen #1128 merged (that branch carried theDockerfile.productionchange).Why the existing guard missed it
test_dockerfile_production_pins_dependency_floorsonly validates packages already present in the install list — it never asserts that every canonical runtime import resolves to an installed pin. So a missing required package is invisible to it. Worth hardening separately (e.g. a build-stagepython -c "import youtube_extension.main"smoke check, or extending the entrypoint test to assert the CMD module's third-party imports are all installed) so this class can't recur; not done here to keep the fix minimal.Verification
Risk
Minimal. Adds one required runtime dependency to the image; touches no application code and no other package floor.
Note for maintainers (separate issue, not in this PR)
CI
gitleaks (working tree)is red onmaindue to a false positive:uv.lock:5129is theparso-0.8.7.tar.gzsha256:package hash, matched by thesquare-access-tokenrule. Not a credential. Recommend an allowlist in.gitleaks.toml(path rule foruv.lockpackage hashes, or the fingerprintuv.lock:square-access-token:5129). Left out of this PR since editing the secret-scanner config is better done deliberately.Generated by Claude Code