Closed
Conversation
added 3 commits
April 21, 2026 17:48
This fix addresses issue #761 where deploying with valid AWS credentials for a different account than the target would fail late in the process at the 'publish assets' step with a generic error. Changes: - Add AccountMismatchError class with clear error messages including both account IDs and fix instructions - Add validateAccountMatch() function that compares credentials account with target account using STS GetCallerIdentity - Add isAccountMismatchError() helper function in errors.ts - Update validateProject() in preflight.ts to validate account match early (before build/synth steps) - Update handleDeploy() in actions.ts to use validateAccountMatch for teardown deploys - Update useCdkPreflight hook to handle AccountMismatchError properly - Add comprehensive unit tests for account mismatch validation The fix ensures users get immediate feedback when their credentials don't match the target account, rather than waiting for deployment to fail at the 'publish assets' step.
HIGH: Document that only first target is validated (deploys target one account at a time) - Added comment explaining multi-target deployments require separate deploy commands MEDIUM fixes: - Extract createNoCredentialsError() helper to eliminate duplicate error handling - Improve error message to distinguish 'not configured' vs 'detection failed' - Add shortMessage property to AccountMismatchError for TUI consistency - Use err.shortMessage in TUI hook instead of hardcoded string - Add target.account validation (12-digit AWS account ID) in deploy actions - Refactor import-utils.ts to use validateAccountMatch() instead of manual logic - Improve isAccountMismatchError() to check specific properties for type safety LOW fixes: - Export AccountMismatchError and validateAccountMatch from aws/index.ts - Remove non-null assertion in preflight.ts, use explicit if (target) check - Update test comments to clarify detectAccount null return behavior - Add test for AccountMismatchError.shortMessage property - Update test assertions to match new error message wording
MEDIUM fixes: - useCdkPreflight.ts:294: Handle AccountMismatchError in validateProject catch block to use shortMessage in interactive mode, matching the pattern at line 328 - errors.test.ts: Add test coverage for isAccessDeniedError function - errors.test.ts: Add test coverage for isAccountMismatchError function - preflight.test.ts: Add tests for account mismatch scenarios including: - Throws AccountMismatchError when credentials don't match target - Validates against first target when multiple targets exist - Falls back to validateAwsCredentials when no targets configured - Skips credential validation for teardown deploys LOW fixes: - account-extended.test.ts: Add explanatory comment for AccessDenied handling during STS:GetCallerIdentity (credentials error vs authorization error) Note: useCdkPreflight hook test file not created as it would require extensive React testing infrastructure setup. The critical error handling paths are now covered by the preflight.test.ts tests.
Contributor
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-903-tarball/aws-agentcore-0.9.1.tgz |
Contributor
Coverage Report
|
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.
This is end to end AI generated please do not merge this is for testing
Summary\nFixes https://github.com/aws/agentcore-cli/issues/761\n\nRound 1: 19 findings
Round 2: 7 findings
Round 3: 0 findings, all approved