Skip to content

fix(recommendation): resolve --bundle-version LATEST to deployed versionId#1566

Open
jariy17 wants to merge 1 commit into
mainfrom
fix/reco-bundle-version-latest
Open

fix(recommendation): resolve --bundle-version LATEST to deployed versionId#1566
jariy17 wants to merge 1 commit into
mainfrom
fix/reco-bundle-version-latest

Conversation

@jariy17

@jariy17 jariy17 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

agentcore run recommendation --bundle-version LATEST now resolves LATEST to the config bundle's deployed version UUID before calling the recommendation API.

Fixes #1565.

Why

The recommendation path passed the literal string LATEST straight through to the config-bundle API (.../configuration-bundles/<bundle-id>/versions/LATEST), which only accepts a concrete version UUID. The call failed with:

400 ... Value at 'versionId' failed to satisfy constraint:
Member must satisfy regular expression pattern: [a-f0-9]{8}-[a-f0-9]{4}-...

The run ab-test config-bundle path already resolves LATEST (via resolveConfigBundleVersion), so the two code paths were inconsistent. Users had to manually pass an explicit version UUID as a workaround.

What changed

  • Added resolveBundleVersionId(bundleArn, versionRef, deployedState) in recommendation/build-config.ts. It returns an explicit version verbatim, expands LATEST to the bundle's deployed versionId (looked up by ARN from deployed state), and returns undefined when LATEST can't be resolved (bundle not deployed). This mirrors the ab-test helper.
  • recommendation/handler.ts now resolves the version before building the request. If LATEST can't be resolved it surfaces a friendly ResourceNotFoundError ("Run agentcore deploy first, or pass an explicit version UUID.") instead of sending LATEST to the API.
  • Added unit tests for resolveBundleVersionId (explicit passthrough, LATEST resolution, unresolved bundle, empty targets).

Testing

  • npm run typecheck — pass
  • eslint on changed files — clean
  • vitest run src/cli/operations/jobs/recommendation/ — 42 passed (incl. 4 new)
  • Manually verified against a deployed project (@aws/agentcore 0.20.0): --bundle-version LATEST previously returned a 400; the equivalent flow with an explicit UUID succeeds, and this change makes LATEST resolve to that same UUID.

…ionId

`agentcore run recommendation --bundle-version LATEST` passed the literal
string "LATEST" through to the config-bundle API path
(.../configuration-bundles/<id>/versions/LATEST), which only accepts a
concrete version UUID, so the command failed with a 400 validation error.
The ab-test config-bundle path already resolves LATEST; the recommendation
path did not.

Resolve LATEST to the bundle's deployed versionId (looked up by ARN from
deployed state) before building the request, mirroring the ab-test
resolveConfigBundleVersion helper. When LATEST cannot be resolved (bundle not
deployed) we surface a friendly ResourceNotFoundError instead of sending
"LATEST" to the API.

Adds unit tests for the new resolveBundleVersionId helper.
@jariy17 jariy17 requested a review from a team June 17, 2026 22:27
@github-actions github-actions Bot added the size/s PR size: S label Jun 17, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 17, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Jun 17, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.20.0.tgz

How to install

gh release download pr-1566-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.20.0.tgz

@agentcore-cli-automation agentcore-cli-automation left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — small, focused fix that mirrors the existing ab-test resolveConfigBundleVersion helper and addresses the 400 documented in #1565.

A few things I checked and was happy with:

  • The handler's resolvedBundleVersion === 'LATEST' guard correctly handles opts.bundleVersion === undefined (no false positives), and bundleArn is guaranteed to be set by the earlier ResourceNotFoundError branch when inputSource === 'config-bundle'.
  • resolveBundleVersionId looks up by ARN across all targets, which is strictly more capable than the ab-test helper (which only matches by name) — this means it also works when the user passes --bundle-name <ARN> directly, as long as that ARN exists in deployed state.
  • Test uses real types and only stubs the DeployedState shape via as unknown as; no excessive mocking.
  • This is a bug fix, not a new feature, and the existing recommendationHandler.create flow has no telemetry instrumentation, so no new telemetry expected here.

No blocking issues from me.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 36.78% 13440 / 36537
🔵 Statements 36.08% 14294 / 39614
🔵 Functions 31.21% 2286 / 7323
🔵 Branches 30.54% 8868 / 29033
Generated in workflow #3686 for commit 93483ed by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run recommendation does not resolve --bundle-version LATEST (sends literal 'LATEST', 400)

2 participants