fix(cli): No deploy-path or CDK change needed (field + wiring alrea... (#870)#54
Draft
aidandaly24 wants to merge 1 commit into
Draft
fix(cli): No deploy-path or CDK change needed (field + wiring alrea... (#870)#54aidandaly24 wants to merge 1 commit into
aidandaly24 wants to merge 1 commit into
Conversation
CLI flag enhancement only: add `--execution-role-arn` to `agentcore add agent` and wire it into the create + BYO non-interactive add paths. No deploy-path or CDK changes (field + wiring already correct at pinned CDK tag). Import path intentionally untouched (imported agents derive their role). The unknown-key silent-strip hardening was left out of scope. Refs aws#870
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.
Refs aws#870
Issues
agentcore add agentexposes no --execution-role-arn (or equivalent) option. Worse, guessing the field name "roleArn" in agentcore.json passesagentcore validatecleanly yet is silently dropped at deploy, so the CLI creates its own CDK-managed role and the user's role is ignored with zero warning. The supported field (executionRoleArn) does work in agentcore.json and was undocumented until PR docs: document executionRoleArn in runtime spec aws/agentcore-cli#872, but it is non-obvious and there is still no command-line flag and no warning on the typo'd key.Root cause
Two things, neither a deploy-path code defect. (1) Field-name UX/footgun: AgentEnvSpecSchema is a non-strict z.object().superRefine() (src/schema/schemas/agent-env.ts:306-447); the supported key is executionRoleArn (agent-env.ts:335, doc comment :334). Zod object schemas strip unknown keys, so the reporter's "roleArn" is silently dropped at ConfigIO.readProjectSpec parse time (src/lib/schemas/io/config-io.ts:113,325 via AgentCoreProjectSpecSchema -> agents array of AgentEnvSpecSchema at src/schema/schemas/agentcore-project.ts:399). validate and deploy share that parse, so validate passes (action.ts:185-194) yet deploy makes a CDK-managed role. (2) Missing flag / discoverability: the correct field exists and is fully wired — cdk-stack.ts:114 passes the whole spec to AgentCoreApplication, AgentEnvironment.ts:53/78 (CDK v0.1.0-alpha.19) hands the agent to AgentCoreRuntime, which at AgentCoreRuntime.ts:56 sets useImportedRole = !!agent.executionRoleArn, :59 iam.Role.fromRoleArn(...,{mutable:false}), :202 passes roleArn to CfnRuntime (all verified at tag v0.1.0-alpha.19, the pinned ^0.1.0-alpha.19) — but AgentPrimitive.tsx option block (lines 254-326) registers NO execution-role flag, so the capability is config-only and undiscoverable from the CLI. Docs gap was real and is now fixed (commit abfd33b / PR aws#872, docs/configuration.md:196). I downgrade the brief's already-fixed: functional workaround and docs are in place, but the CLI flag the issue explicitly requests does not exist at v0.20.2 and the silent-strip footgun remains.
The fix
No deploy-path or CDK change needed (field + wiring already correct at pinned versions). Actionable work, both in CLI: (1) Expose executionRoleArn as a flag — add a Commander .option('--execution-role-arn ', ...) in src/cli/primitives/AgentPrimitive.tsx (option block ~254-326, currently has --network-mode/--authorizer-type but no role flag) and map it onto spec.executionRoleArn in the non-interactive add path (optionally on
agentcore createtoo). (2) UX hardening for the silent strip: have validate/parse warn on unknown top-level runtime keys (or switch AgentEnvSpecSchema to a strict variant in validate) so a future roleArn-style typo surfaces instead of being dropped silently — this is what would have saved the reporter. Docs already done (docs/configuration.md:196, PR aws#872).Files touched: Flag enhancement: src/cli/primitives/AgentPrimitive.tsx (option registration ~lines 254-326 + the non-interactive add handler that builds AgentEnvSpec). Unknown-key warning: src/cli/commands/validate/action.ts (and/or AgentEnvSpecSchema in src/schema/schemas/agent-env.ts:306). Field/wiring already correct (no change): src/schema/schemas/agent-env.ts:334-335; src/assets/cdk/lib/cdk-stack.ts:114; @aws/agentcore-cdk AgentEnvironment.ts:53/78 and AgentCoreRuntime.ts:56,59,202 at tag v0.1.0-alpha.19. Docs already fixed: docs/configuration.md:196.
Validation evidence
The fix was verified by reproducing the original symptom and re-running after the change:
Test suite: green.
Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.