aws-samples / aws-samples/sample-autonomous-cloud-coding-agents
fix(cli): repo onboard --model accepts any string, so an un-granted model fails at turn 0 with no explanation
- Lingua principale
- TypeScript
- Stelle
- 146
- Fork
- 46
- Merge medio
- 3g 10h
- PR unite (30g)
- 24
Descrizione
## Problem
`bgagent repo onboard --model ` writes whatever string it is given to the RepoTable. Nothing validates it, so two easy mistakes both produce the same opaque outcome:
- a model that is not in the IAM grant (`bedrockModels` / `DEFAULT_BEDROCK_MODEL_IDS`);
- a geo prefix that does not match the deployment's `bedrockGeoRegion` — e.g. `us.anthropic.claude-opus-5` on a stack configured for `global`.
Either way the task dispatches, runs, and fails at **turn 0** with `AccessDenied`. Nothing at onboard time, and nothing in the failure, says the model was the cause.
That is the same failure shape the code already guards against elsewhere. `resolveBedrockModelIds` rejects a geo-prefixed entry at synth, and `workflows.ts` carries a comment warning that a model on the allow-list but not granted "passes admission and then fails at turn 0 with AccessDenied". The `repo --model` path has neither guard.
## Suggested change
Validate at the CLI boundary, where the operator can still fix it:
1. Reject a **bare** foundation-model id — it cannot be invoked on demand, so it is always wrong here (`ValidationException` at runtime). Point at the geo-prefixed form.
2. Warn, or fail, when the geo prefix does not match the deployment's `bedrockGeoRegion`.
3. Ideally check membership in the granted set. That needs the grant list reachable from the CLI — a stack output, or the API surfacing it — so it may be a second step.
Even (1) and (2) alone convert the most common mistakes from a turn-0 `AccessDenied` into an immediate message.
## Related gap
`submit` exposes no `--model` at all, so a per-task model override is not reachable from the CLI — you have to flip the repo config between runs to compare two models. Possibly worth its own issue; noting it here because it is the same surface.
## Scope
`cli/src/commands/repo.ts` (the `--model` option), plus tests. Needs a decision on where the CLI learns the granted set for (3).
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.