Repository navigation
fix(validate): stop reporting a deployed Lambda as missing, and point remediation somewhere real (#790) - #791
Merged
Conversation
… remediation somewhere real (#790) `spawn validate --infrastructure` is the command whose whole job is saying whether the control plane is healthy. Against the live shared account it reported two errors, one of which was false, and then recommended a command that does not exist. ## The false error The scheduler handler is deployed as `scheduler-handler`, with no prefix: scripts/deploy-scheduler-handler.sh defaults to `SPAWN_LAMBDA_NAME:-scheduler-handler`. The resolver rebuilt the name from the prefix convention and asked for `spawn-scheduler-handler`, which has never existed anywhere. Scheduling itself was never broken — cmd/schedule.go has always invoked the unprefixed name. Only the health check was wrong, which is the worse place for it to be: an operator who cannot trust the report has to re-derive which half to believe. Three places agreed with the bug: the resolver, its unit test, and the Substrate fixture. The fixture now provisions from the same constants the resolver uses. The unit test deliberately keeps LITERAL ARNs — a test that restates the value under test cannot notice it being wrong, which is how this survived. Division of labour: resolver_test trips when a name changes; lambda_names_test decides whether the new name is real. ## The dead-end remediation It recommended `spawn config deploy-infrastructure` and `spawn config init --self-hosted`. Neither exists; both have been there since the initial commit. And because `config` is an alias for `instance-config`, following the advice did not even give an "unknown command" error — it tried to read runtime config over SSH from an instance named "deploy-infrastructure". Now: missing Lambdas are named one per line with the script that deploys each; missing tables with the setup script or template that creates them; self-hosted mode with the config keys and SPAWN_LAMBDA_*_ARN variables that actually drive it. Where nothing in the repo deploys a function, it says so instead of inventing a command — which is the honest answer for alert-handler, and names #783. ## Gates TestEveryHardcodedLambdaNameIsCreatedByADeployMechanism reads function names out of every deploy script and template and fails when Go source hardcodes one that none of them create. Discovered, not listed: writing the convention down a second time is what drifted the first time. It found ten created names, two of which nobody had enumerated by hand (dashboard-websocket, dashboard-websocket-processor). TestValidateRecommendationsNameOnlyRealCommandsAndPaths resolves every command a recommendation mentions against the real cobra tree, and checks every path exists. It lives in cmd/ because the cobra tree is the only authority on what exists, and checking the first word would not have helped: `config` IS a real command and the defect was the subcommand. ## Verifying the gates, which took two attempts Reverting the name passes `go build` and `go vet`, and the name gate fails on it with the right diagnostic. The recommendation gate initially did NOT catch two of the three defects. The Lambda branch names mechanisms per function when it has resource detail and falls back to one generic line when it does not; my fixture populated Resources, so the fallback string was unreachable and restoring the original text there PASSED. That is the #787 shape exactly. The fixture now drives both shapes and asserts the fallback is non-empty, and all three original strings fail it — bare, backticked, and the `--self-hosted` flag on a command with no such flag. ## Verified against the live account Before: 2 errors, 2/4 Lambdas accessible, remediation to a nonexistent command. After: 1 error (alert-handler, which is real), 3/4 accessible, `✓ scheduler-handler`, and a recommendation naming `spawn alerts create` and issue #783. make check green including all 12 nested modules; check-docs, API surface, changelog and semgrep (0 findings, 414 rules) clean. Public API surface unchanged, correctly: pkg/infrastructure is not imported by another repo.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the two decision-free defects in #790. Refs #790 rather than closing
it — the third defect (the
spawn alertsCLI accepting alerts nothing candeliver) is still open and is independent of the #783 product call.
Before and after, against the live shared account
1. The false error
The function is deployed as
scheduler-handler, no prefix —scripts/deploy-scheduler-handler.shdefaults toSPAWN_LAMBDA_NAME:-scheduler-handler. The resolver rebuilt the name from theprefix convention and asked for
spawn-scheduler-handler, which has neverexisted.
Scheduling was never broken;
cmd/schedule.gohas always invoked the unprefixedname. Only the health check was wrong — the worse place for it, since an operator
who can't trust the report has to re-derive which half to believe.
Three places agreed with the bug: the resolver, its unit test, and the
Substrate fixture. The fixture now provisions from the same constants the
resolver uses; the unit test deliberately keeps literal ARNs, because a test
that restates the value under test cannot notice it being wrong. That split is
the point —
resolver_testtrips when a name changes,lambda_names_testdecides whether the new name is real.
2. The dead-end remediation
spawn config deploy-infrastructureandspawn config init --self-hosteddo notexist, and both predate every other commit. Because
configis an alias forinstance-config, following the advice didn't even yield "unknown command" — ittried to read runtime config over SSH from an instance named
deploy-infrastructure.Recommendations now name the real mechanism per resource, and where nothing in
the repo deploys a function they say so instead of inventing a command.
Gates, and the one that didn't work first time
TestEveryHardcodedLambdaNameIsCreatedByADeployMechanism— reads names out ofevery deploy script and template, fails when Go source hardcodes one none of
them create. Discovered, not listed: writing the convention down a second time
is what drifted the first time. It found ten created names, two of which nobody
had enumerated by hand.
TestValidateRecommendationsNameOnlyRealCommandsAndPaths— resolves everycommand against the real cobra tree and checks every path exists. In
cmd/because the cobra tree is the only authority. Checking the first word wouldn't
have helped:
configis real; the defect was the subcommand.The second gate initially missed two of the three defects, and running the
reverts is the only reason I know. The Lambda branch names mechanisms per
function when it has resource detail and falls back to one generic line when it
doesn't; my fixture populated
Resources, so the fallback string wasunreachable and restoring the original text there passed. That is the #787
shape precisely — a gate that cannot reach the string it guards. The fixture now
drives both shapes and asserts the fallback is non-empty; all three original
strings now fail it (bare, backticked, and
--self-hostedon a command with nosuch flag). The name gate was confirmed against a revert that builds and vets
clean.
Verification
make checkgreen including all 12 nested modules;check-docs, API surface,changelog and
semgrep(0 findings, 414 rules) clean. Public API surfaceunchanged, correctly —
pkg/infrastructureis not imported by another repo.Live run above is read-only; no AWS state was changed.