Repository navigation
fix(deploy): only warn about --region on v0 projects when it was explicitly passed - #2603
Conversation
…icitly passed #2601 added a warning for --region being silently ignored on v0 deploys, but checked ctx.value(RegionKey) !== undefined -- which is never undefined by the time a handler runs, since withRegion() always overwrites it with a resolved value (flag -> env -> config -> default) before any handler sees it. So the warning fired on every v0 deploy, including agentcore dev, even with no --region passed at all. Add RegionExplicitKey, set by withRegion() from the raw flag value before it resolves/overwrites RegionKey, and check that instead. RegionKey itself is untouched -- every other reader of it keeps working exactly as before. Also, per review: - Move the warning (and the migration check it was duplicated around) into delegateV0Deploy itself, called from both entry points, instead of being duplicated at each call site. - Warn even under --json: stderr carries informational lines regardless of --json (matching the existing "Deployed project ..." precedent), so a scripted caller passing --region on a v0 project still finds out. - Reword the message: v0 also falls back to AWS_REGION/the AWS profile, not only aws-targets.json. - Add the missing no-flag regression test, and tighten the existing `dev` test from toContain(...) to an exact match so it actually catches a spurious warning.
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Nice fix. The prior warnIfRegionIgnored check (ctx.value(RegionKey) !== undefined) was effectively always true after withRegion ran, which meant the warning fired on every v0 deploy regardless of whether --region was actually passed. Splitting the "did the user ask?" bit into a dedicated RegionExplicitKey captured before withRegion resolves the default is the right shape, and threading it through the middleware keeps the detection away from flag parsing internals.
A few things I checked that look correct:
withRegionis installed at the root (src/handlers/index.tsx), so every routed command seesRegionExplicitKeyset to a real boolean before the deploy handler runs. Theagentcore dev→createDeployProjectHandler(...).handle(ctx, ...)passthrough also inherits the same ctx, so dev invoking a v0 deploy will still warn correctly when--regionwas passed todev.- Computing
explicitfromctx.value(RegionKey)before the ctx is replaced with the resolved region is the only correct ordering, and that's what the diff does. - Emitting the warning even with
--jsonis right — stderr is informational and isn't part of the JSON output contract; the test matrix now covers both--yesand--jsonpaths. - The new "does not warn about --region when it was never passed" test closes the regression the previous implementation would have missed.
No telemetry gap worth flagging (warning-message bug fix), and the tests use real temp dirs rather than fs mocks.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2603 +/- ##
============================================
- Coverage 96.58% 96.58% -0.01%
============================================
Files 700 700
Lines 57639 57638 -1
============================================
- Hits 55673 55672 -1
Misses 1966 1966 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What
Follow-up to #2601 (merged). That PR added a warning for
--regionbeing silently ignored on v0 deploys, but the warning fired on every v0 deploy (and everyagentcore devon a v0 project), even when--regionwas never passed at all.Why
#2601checkedctx.value(RegionKey) !== undefinedto decide whether to warn. That's neverundefinedby the time a handler runs:withRegion()(src/middleware/withRegion.tsx) always overwritesRegionKeywith a fully-resolved value (flag → env → config →DEFAULT_REGION) before any handler sees it. So the check was always true, and the warning became unconditional noise on every v0 deploy — caught in review on #2601 before merge, filed here as the fix.How
RegionExplicitKey(src/handlers/keys.tsx) — a separate context key holding whether--regionwas actually passed, set bywithRegion()from the raw flag value before it resolves and overwritesRegionKey.RegionKeyitself and every other reader of it (deploy/index.ts's v1 native path,dev/index.ts,resolveRegion()) are untouched.RegionExplicitKeyinstead.assertNoPendingMigrationcheck it was duplicated around) intodelegateV0Deployitself, called once from both entry points, instead of being duplicated at each call site.--json— stderr carries informational lines regardless of--json(matching the existingdeployedMessageprecedent), so a scripted caller passing--regionon a v0 project still finds out.AWS_REGION/the AWS profile, not onlyaws-targets.json.--region), and tightened the existingdevtest fromtoContain(...)to an exact match so it actually catches a spurious warning like this one.Testing
bun test(4574 pass, 0 fail)bun run typecheckbun run lint:checkbun run format:checkbun run buildChecklist