Skip to content

build(deps): Let Dependabot recompile Lambda locks - #208

Open
andreameroni wants to merge 4 commits into
mainfrom
build/dependabot-uv-lambda-locks
Open

andreameroni wants to merge 4 commits into
mainfrom
build/dependabot-uv-lambda-locks

Conversation

@andreameroni

@andreameroni andreameroni commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this change do?

Lets Dependabot security updates regenerate the Lambda lockfiles that CDK deploys.

Each Lambda layer had a hand-edited requirements.txt and a requirements.lock compiled by backend/scripts/compile.sh. Dependabot's uv ecosystem only pairs a requirements.in source with a requirements.txt output, so it never saw the .lock files. No Dependabot alert has ever been raised against them, and every Lambda lockfile update was made by hand (#79, #123, #156). An alert on backend/uv.lock could close while the deployed Lambdas kept the vulnerable version (#150).

  • In the nine Lambda directories, requirements.txt becomes requirements.in and requirements.lock becomes requirements.txt. Pins and hashes are unchanged; only the # via and header comments differ.
  • compile.sh, backend_app_function.py, shared_layer.py, test_runtime_stub_dependencies.py, the -r includes and the backend README use the new names. The constructs read requirements.txt directly instead of falling back from .lock.
  • .github/dependabot.yml adds a uv entry for the nine directories with open-pull-requests-limit: 0, so only security updates open PRs.
  • ci.yml adds a backend step that reruns compile.sh and fails when a lockfile changes outside comment lines.
  • ci.yml adds a backend step that installs each Lambda requirements.txt into a temp dir with the uv_target_args flags CDK bundling uses (python3.13, arm64). A stale hash or a missing wheel fails the PR.
  • requirements-txt-fixer also covers .in files.
  • ci.yml adds a frontend-infrastructure job: yarn install --immutable, the high+ audit, lint, tests and build. The frontend job only covered frontend/web, so a Dependabot PR on frontend/infrastructure passed CI without its yarn.lock being installed.

Type of change

  • Bug fix
  • New feature
  • Refactor / tech debt
  • Documentation
  • Infrastructure / CI

How was this tested?

  • uv run pytest app -n auto: 2854 passed.
  • pytest app/shared/tests/test_runtime_stub_dependencies.py infra/constructs/tests: 49 passed, same as on main. Removing a stub pin from a Lambda requirements.txt fails the stub test.
  • pre-commit on the changed files passes.
  • Dependabot CLI v1.97.0 with the dependabot-updater-uv image and simulated advisories, on this branch:
    • certifi (transitive) in /backend/app/shared: PR created, requirements.txt regenerated with uv pip compile --generate-hashes --python-version=3.13 -P certifi requirements.in.
    • aws-xray-sdk (direct): PR created, requirements.in raised from ~= 2.12 to ~= 2.16 and requirements.txt regenerated.
    • Pins and hashes in both match compile.sh output, and the CI drift step passes on both.
  • The same certifi job on main returns security_update_dependency_not_found.
  • The drift step fails when a .in file changes without a recompile and when a package is removed from a lockfile.
  • frontend/infrastructure: install, audit, lint, build and yarn test:ci (78 tests) pass locally.
  • Lambda install step: passes on all nine lockfiles; fails on a pin changed without its hashes and when the target flags are invalid.

Checklist

  • Follows the guidance in CONTRIBUTING.md
  • Tests added/updated and passing locally
  • Lint / type checks pass locally
  • No secrets, credentials, or account IDs committed
  • Docs updated if behavior or usage changed
  • Linked the related issue (if any): closes #

Notes for reviewers

  • The drift step ignores comment lines because Dependabot compiles inside each Lambda directory, so its # via lines name requirements.in instead of app/shared/requirements.in.
  • CDK synth was not run.

Acknowledgment

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Andrea Meroni added 2 commits November 17, 2026 21:07
Rename each Lambda requirements.txt source to requirements.in and each
requirements.lock to requirements.txt. Dependabot's uv ecosystem only
pairs .in sources with .txt outputs, and only then reruns
uv pip compile, so the old names left the deployed Lambda pins outside
Dependabot and outside the dependency graph.

Add a uv entry for the nine Lambda directories with version updates
off, so security updates use uv. Add a CI step that reruns compile.sh
and fails when any lockfile changes.
A local Dependabot run showed that its uv pip compile runs inside each
Lambda directory, so its "# via" lines name requirements.in and omit
the workspace override note. Pins and hashes matched compile.sh, but
the plain git diff failed every Dependabot PR.
@andreameroni
andreameroni requested a review from a team November 18, 2026 07:55
Andrea Meroni added 2 commits November 18, 2026 09:18
The frontend job only installs and audits frontend/web, so a Dependabot
PR on frontend/infrastructure passed CI without its yarn.lock being
installed. That directory builds the Lambda@Edge auth handler. The new
job runs install --immutable, the high+ audit, lint, tests and build.
The drift check proves each lockfile matches compile.sh, but not that it installs. Install each one into a temp dir with the uv_target_args flags that CDK bundling uses, so a stale hash or a missing wheel for python3.13 on arm64 fails the PR instead of the deployment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants