Skip to content

fix(deploy): only warn about --region on v0 projects when it was explicitly passed - #2603

Merged
jariy17 merged 1 commit into
refactorfrom
fix/v0-deploy-region-explicit-warning
Oct 16, 2026
Merged

jariy17 merged 1 commit into
refactorfrom
fix/v0-deploy-region-explicit-warning

Conversation

@jariy17

@jariy17 jariy17 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

What

Follow-up to #2601 (merged). That PR added a warning for --region being silently ignored on v0 deploys, but the warning fired on every v0 deploy (and every agentcore dev on a v0 project), even when --region was never passed at all.

Why

#2601 checked ctx.value(RegionKey) !== undefined to decide whether to warn. That's never undefined by the time a handler runs: withRegion() (src/middleware/withRegion.tsx) always overwrites RegionKey with 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

  • Added RegionExplicitKey (src/handlers/keys.tsx) — a separate context key holding whether --region was actually passed, set by withRegion() from the raw flag value before it resolves and overwrites RegionKey. RegionKey itself and every other reader of it (deploy/index.ts's v1 native path, dev/index.ts, resolveRegion()) are untouched.
  • The warning now checks RegionExplicitKey instead.
  • Moved the warning (and the assertNoPendingMigration check it was duplicated around) into delegateV0Deploy itself, called once from both entry points, instead of being duplicated at each call site.
  • The warning now prints even under --json — stderr carries informational lines regardless of --json (matching the existing deployedMessage precedent), so a scripted caller passing --region on a v0 project still finds out.
  • Reworded the message: v0 also falls back to AWS_REGION/the AWS profile, not only aws-targets.json.
  • Added the missing no-flag regression test (asserts the warning does not fire with no --region), and tightened the existing dev test from toContain(...) to an exact match so it actually catches a spurious warning like this one.

Testing

Checklist

…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.
@github-actions github-actions Bot added the size/s PR size: S label Oct 15, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Oct 15, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Oct 15, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • withRegion is installed at the root (src/handlers/index.tsx), so every routed command sees RegionExplicitKey set to a real boolean before the deploy handler runs. The agentcore dev → createDeployProjectHandler(...).handle(ctx, ...) passthrough also inherits the same ctx, so dev invoking a v0 deploy will still warn correctly when --region was passed to dev.
  • Computing explicit from ctx.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 --json is right — stderr is informational and isn't part of the JSON output contract; the test matrix now covers both --yes and --json paths.
  • 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.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Oct 15, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.58%. Comparing base (3fb8f16) to head (99af320).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nborges-aws nborges-aws left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jariy17
jariy17 merged commit fdf9cf2 into refactor Oct 16, 2026
22 of 23 checks passed
@jariy17
jariy17 deleted the fix/v0-deploy-region-explicit-warning branch October 16, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants