Skip to content

chore: untrack the 22 MiB lambda binary and gate against tracked executables - #644

Merged
scttfrdmn merged 1 commit into
mainfrom
chore/637-untrack-lambda-binary
Oct 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
chore/637-untrack-lambda-binary

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #637.

What was wrong

lambda/autoscale-orchestrator/autoscale-orchestrator was the one name missing from .gitignore's hand-maintained per-lambda list, so it was tracked and mutable. A plain go build ./... in that module — which CI itself runs on every lambda module — rewrote it, and git add -A then staged a 22 MiB diff. That caught me twice in one session, which is what makes it a live footgun rather than cosmetic debt.

Checked before deleting

The issue flagged that a tracked binary "suggests something may have depended on it", so that came first:

  • The Makefile builds bootstrap (BINARY_NAME=bootstrap) and zips that. clean removes bootstrap and function.zip and doesn't know this file exists.
  • Every other autoscale-orchestrator reference in the repo is the Lambda function name (spawn-autoscale-orchestrator-${Environment}) or the sts ExternalId — never a file path.
  • The committed bytes are Mach-O arm64 — a macOS build. The function is provided.al2023/arm64 Linux, so this binary could never have run on Lambda to begin with. It's definitively dead.

Found while verifying

template.yaml uses CodeUri: . with no .samignore, so SAM packages the whole directory — meaning this dead 22 MiB binary has been riding inside every deployed artifact. (du -sh on the directory is 22M, essentially all this one file.)

I deliberately did not change deploy packaging here. Adding a .samignore touches how a real Lambda gets built and I can't exercise a sam deploy to prove it safe, so it's noted on the issue as a separate item rather than smuggled into a cleanup PR.

The gates

The issue's option 1 suggested generalising the .gitignore pattern. That isn't expressible — go build names output after the module directory, so the pattern is lambda/<name>/<name> and gitignore can't say "same name as parent". So the .gitignore line stays explicit, and the generalisation lives in tests instead (the issue's option 3):

  • TestNoTrackedCompiledBinaries — fails if any tracked file is a compiled executable. Matches magic bytes, not file output: file describes every shell and Python script here as "... text executable", and there are 20+ of those under lambda/ alone (deploy.sh, handler.py, the dashboard-api setup scripts), so a substring check on "executable" would fail on all of them — which is how a gate like this gets deleted instead of fixed. Scanned repo-wide: exactly one file matched before this change.
  • TestEveryGoLambdaBinaryIsIgnored — fails if a Go lambda module has no .gitignore entry for its build output, catching the omission at the source rather than after a binary is already committed. Scoped to modules with a go.mod, so the Python github-oauth lambda (handler.py, no Go build) isn't flagged — my first pass reported it as missing, which was a false alarm.

Both confirmed to fail when inverted: re-adding the binary trips the first (Mach-O 64-bit), deleting the ttl-reaper line trips the second.

Scope note

Removing this from HEAD does not shrink existing clones — the bytes stay in history. It stops the bleeding; a history rewrite isn't worth it, as the issue says.

Verification

  • gofmt, go vet, full go test -short ./..., changelog gate — all green.
  • Ran the exact footgun afterwards: go build ./... in lambda/autoscale-orchestrator now leaves git status clean.
  • semgrep run locally this time (--config=auto --error): 0 findings.
  • No behaviour change, no new dependencies. The only .go file is a _test.go, so the changelog gate doesn't fire — I added an entry anyway, since a 22 MiB removal is worth recording for contributors.

…utables

lambda/autoscale-orchestrator/autoscale-orchestrator was the single name missing
from .gitignore's hand-maintained per-lambda list, so it was tracked and
mutable. A plain `go build ./...` in that module — which CI itself runs on every
lambda module — rewrote it, and `git add -A` then staged a 22 MiB diff. That
happened to me twice in one session, which is what makes it a live footgun
rather than cosmetic debt.

Verified nothing depended on the path before deleting it:

  - The Makefile builds `bootstrap` (BINARY_NAME=bootstrap) and zips that;
    `clean` removes bootstrap and function.zip and does not know this file
    exists.
  - Every other reference to "autoscale-orchestrator" in the repo is the Lambda
    FUNCTION name (spawn-autoscale-orchestrator-${Environment}) or the sts
    ExternalId — not a file path.
  - The committed bytes are Mach-O arm64, i.e. a macOS build. The function is
    provided.al2023/arm64 Linux, so this binary could never have run on Lambda
    at all.

Also found: template.yaml uses `CodeUri: .` with no .samignore, so SAM packages
the whole directory — the dead 22 MiB binary has been riding inside every
deployed artifact (the directory is 22M, essentially all of it this file).
Deliberately NOT changing deploy packaging here; noted on the issue instead,
since I can't exercise a sam deploy to prove a .samignore safe.

Two gates replace the hand-maintained list as the actual protection:

  - TestNoTrackedCompiledBinaries — fails if any tracked file is a compiled
    executable. Matches MAGIC BYTES, not `file` output: `file` describes every
    shell and Python script here as "... text executable", and there are 20+ of
    those under lambda/ alone, so a substring check would fail on all of them.
    Exactly one file in the repo matched before this change.
  - TestEveryGoLambdaBinaryIsIgnored — fails if a Go lambda module has no
    .gitignore entry for its build output, catching the omission at the source
    instead of after a binary is committed. Scoped to modules with a go.mod, so
    the Python github-oauth lambda (handler.py, no Go build) isn't flagged.

Both confirmed to fail when inverted: re-adding the binary trips the first, and
deleting the ttl-reaper line trips the second.

Removing this from HEAD does not shrink existing clones — the bytes remain in
history — but it stops the bleeding. A history rewrite isn't worth it.

Fixes #637
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 242b733 into main Oct 3, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the chore/637-untrack-lambda-binary branch October 3, 2026 21:02
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.

A 22 MiB compiled binary is tracked in git at lambda/autoscale-orchestrator/autoscale-orchestrator

1 participant