fix(project): refuse status outside the project's deployed region - #2241
Merged
Conversation
A bare `project status` links each deployed row to its detail page with ?region=<target>, but the actions those pages open in turn (endpoints, events, detail JSON, …) run in the ambient region, so a project deployed anywhere else breaks one step past the tree (#2239 tried to thread the region through every flow instead). The headless report has the same problem one step later: the ids it prints only work with the same --region. Compare the resolved target's region with the context's before rendering. The CLI throws a ProjectStateError naming both regions; the screen shows the same message in place of the tree and keeps esc as the way out. Rerun with --region <target region> to see the report. The headless tests pin AWS_REGION to the default target's region, since withRegion would otherwise read the developer's shell, and the screen tests pin RegionKey to the target's so the tree still renders; each suite gains a mismatch case of its own. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016KnHdxcPYTnQiDY7Y1PY6s
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
Contributor
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Nice, focused change. The behavior is well-motivated (downstream commands run in the ambient region, so listing IDs from another region invites errors) and the same rule is applied consistently in the headless handler and the TUI screen, with matching wording.
A few observations, none blocking:
- Both
ctx.require(RegionKey)sites are safe:withRegionmiddleware always resolves a value at the root, and the screen test harness (baseContextinsrc/testing/renderScreen.tsx) always pinsRegionKey, matching production behavior. resolveProjectResourcesusestarget.regionfor thedescribeStackcall, so resolution correctly succeeds against the target's region before the ambient-region check gates rendering. That means an out-of-region call still incurs the CloudFormation round-trip, but that's needed to construct a helpful error and matches the TUI's flow.- In
screen.tsx, whenisWrongRegionis true the Layout still advertises↑↓/jk navigate,enter openkey hints even though nothing is focusable. Minor UX polish, not a blocker. - Headless
--jsoncallers now get a thrownProjectStateErrorinstead of a JSON report when they omit--region. That's consistent with otherProjectStateErrorsites in the CLI, so this is fine.
No changes required from me.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2241 +/- ##
=========================================
Coverage 97.04% 97.04%
=========================================
Files 566 566
Lines 39392 39409 +17
=========================================
+ Hits 38227 38244 +17
Misses 1165 1165 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tejaskash
approved these changes
Sep 4, 2026
Hweinstock
approved these changes
Sep 4, 2026
notgitika
approved these changes
Sep 4, 2026
notgitika
reviewed
Sep 4, 2026
| This project is deployed to {status.data.target.region}, not {region} | ||
| </Text> | ||
| )} | ||
| {!isWrongRegion && ( |
Contributor
There was a problem hiding this comment.
maybe we also throw ProjectStateError here
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.
What
project statusnow refuses to describe a project whose target is deployed in a region other than the one the command runs in. The CLI throws aProjectStateErrornaming both regions; the bare TUI shows the same message in place of the Linked Resources tree and keepsescas the way back. Rerun with--region <target region>to see the report.Why
A bare
project statuslinks each deployed row to its detail page with?region=<target>, but the actions those pages open in turn (endpoints, events, detail JSON, …) run in the ambient region, so a project deployed anywhere else broke one step past the tree. #2239 tried to carry the region through every flow instead; this is the smaller guard. The headless report has the same problem one step later: the ids it prints only work with the same--region.How
src/handlers/project/status/index.ts: compare the resolved target's region with the context'sRegionKeyafter resolving resources and before rendering.src/handlers/project/status/screen.tsx:ProjectStatusViewtakes the context, and renders the mismatch message instead of theresourcesheading and tree.Tests
index.test.ts): the suite pinsAWS_REGIONto the default target's region (restored after each test), sincewithRegionwould otherwise read the developer's shell. The--target stagingcase now passes a matching--region. New case: a mismatched target rejects with aProjectStateErrorthat names both regions, an explicit--regiontakes part in the same comparison, and nothing is written to stdout.status.screen.test.tsx):renderStatuspinsRegionKeyto the target's region so the existing tree and navigation tests still apply. New case: with the base context'sus-east-1against aeu-west-1target, the message renders, no agent group or runtime row does,enterstays put, andescreturns to the project menu.Checks
bun test src— 3167 pass. The 11 failures are all insrc/io/exec.test.ts, which spawnsnode, not installed in this environment (same as fix(tui): carry the region override through a resource's whole flow #2239's run).bun run typecheck,bun run lint:check,bun run format:check— clean for the repository's own files.🤖 Generated with Claude Code
https://claude.ai/code/session_016KnHdxcPYTnQiDY7Y1PY6s