Repository navigation
fix(aws-lambda): old stacks are refused before any upload; stale local copies never re-upload - #5909
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
somanshreddy
left a comment
There was a problem hiding this comment.
Reviewed at b716d1d7. No blocker, so I'm approving. One small doc gap is noted below.
What I checked
- Stack check runs first.
render-batchnow callsassertStackReadsSitesbefore bothdeploySiteandsiteHandleFromId, so it also runs with--site-id, and it's skipped only for--dry-run.sites createcalls it first.- Both pass
stack.regionfrom the saved stack state. renderToLambdastill runs its own check per render, using the caller'ssfn.
- Expired-file re-upload only from a matching copy. In
ensureSiteStored, an expiredcas/sha256/file is re-uploaded only when the local copy exists and its sha256 matches the site's listing. An edited or deleted copy now counts as missing, so the render stops withSITE_FILES_MISSINGbefore any upload or execution. This closes my should-fix (1) on #5772. Hashing only happens on the expired path, so it doesn't add work to normal renders. - Tests:
- aws-lambda
renderToLambda.test.tspasses 18 of 18 (bun test), andtscis clean. - CLI
stackCheck.test.ts+render-batch.test.tspass 16 of 16. - Mutation check: dropping the
hasContentcheck fails "refuses when the project dir's copy differs or is gone, uploading nothing".
- aws-lambda
- CI had 24 pass, 16 pending and 0 failing.
Should-fix (docs): sites create now needs states:DescribeStateMachine
docs/deploy/aws-lambda.mdx:179 lists that permission only for code that calls renderToLambda. A CI role that only uploads sites (S3 read/write) would now fail sites create with AccessDenied from Step Functions. Adding "and lambda sites create / render-batch" to that line covers it.
Nit: if a site path resolves to a directory locally, existsSync passes and sha256File throws EISDIR, which is a raw error instead of SITE_FILES_MISSING. That's unlikely, since site paths come from file listings. statSync(...).isFile() would close it.
No live AWS run, same as the PR.
— Somu
Follow-up to #5772 from its review: three gaps in the upgrade path that the main render path already handled.
What changes for users
lambda render-batchandlambda sites createrefuse a too-old stack before uploading anything.render-batchuploaded the site once for the whole batch and only then reached the per-renderSTACK_TOO_OLDcheck, so an old stack received the upload first.sites createnever checked. Both now call the check beforedeploySite, aslambda renderalready does.lambda render --site-idalways passes the project directory. When a file undercas/sha256/had expired and the local copy was gone or edited, the user saw a raw upload error (a missing file, or S3 rejecting the checksum) instead ofSITE_FILES_MISSING. Now a file is re-uploaded only when its local copy hashes to the sha256 the site lists; anything else counts as missing and the render stops withSITE_FILES_MISSINGbefore starting..hyperframes/lambda-stack-<stack-name>.jsonin the current directory) and that the otherlambdacommands read it from there.How
assertStackReadsSites(the checkrenderToLambdaalready ran) is exported from@hyperframes/aws-lambda/sdkand takes{ stateMachineArn, region?, sfn? }.render-batchcalls it unless--dry-run;sites createcalls it first.ensureSiteStoredhashes the local copy before re-storing it.Tests
packages/cli/src/commands/lambda/stackCheck.test.ts(new): with a too-old stack,render-batchandsites createreject withSTACK_TOO_OLDand never calldeploySite. Both fail on the old order.renderToLambda.test.ts: an edited and then a deleted local copy each giveSITE_FILES_MISSINGwith no upload and no execution. Fails without the hash check.renderToLambda.test.ts18/18;stackCheck.test.ts+render-batch.test.ts16/16; each new test red with its fix reverted; 3 consecutive green runs;verify:packed-manifestspasses.Not done