fix: reuse target credential provider for invoke and logs - #2307
Conversation
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Well-scoped fix for a real correctness bug. The change consistently threads the target-verified credential provider from CdkBackend.resolveDeployedResources through ResolvedDeployedResource into the invoke/log handlers, and coreOptsFromCtx picks it up automatically so downstream pickers (RuntimeEndpointPicker, HarnessEndpointPicker, HarnessChat, etc.) inherit the correct account/region binding without extra plumbing.
Things I specifically checked and am comfortable with:
- Trust boundary:
AwsCredentialProvider(narrowed toAwsCredentialIdentityProvider) prevents raw credentials from leaking into the type. Only the provider closure is carried; nothing is persisted. - Target echo comment in
manager.tsx: The existing safeguard ({ ...resource, target: resolved.target }) is preserved;credentialProvideris generated by the backend fromcredentialsForTarget(which assertsaccount === target.account), so trusting the backend echo here is fine. - Coverage of callers:
resolveDeployedResourceis only used byhandlers/project/invoke/{runtime,harness}.tsx,handlers/project/invoke/screen.tsx, andhandlers/project/log/runtime.tsx— all four are updated. Test doubles ininvoke/index.test.tsx,invoke.screen.test.tsx,log/runtime.test.tsx, andcdk.test.tsare all updated to match the new shape. - Two propagation patterns: the invoke path pins into context via
AwsCredentialProviderKey(needed so child components/pickers inherit it viacoreOptsFromCtx), whilelog/runtime.tsxoverridescredentialson the options object directly. Both are correct; the divergence is intentional since the log handler doesn't spawn a TUI that reuses the ctx. - Telemetry: not applicable — this is a bug fix with no new user-facing surface.
No changes requested.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2307 +/- ##
=========================================
Coverage 97.02% 97.02%
=========================================
Files 579 579
Lines 39446 39456 +10
=========================================
+ Hits 38271 38281 +10
Misses 1175 1175 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Hweinstock
left a comment
There was a problem hiding this comment.
make sense, nice well scoped fix!
Description
Fixes bug where
agentcore project invokeused the selected target’s credentials to resolve deployed resources, but used the AWS credential chain for the actual runtime or harness invocation (or cloudwatch request). This could cause a mismatch in the AWS account used for project resolution and project operations.Changes:
AwsCredentialstoAwsCredentialProviderto ensure raw credentials are not acceptedOnly the credential provider function is carried in memory. Raw credentials are not persisted by this change.
Type of Change
Testing
How have you tested the change?
bun run test(3218 pass, 0 fail)npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.