Skip to content

fix: emit ValidationError instead of UnknownError in create telemetry#1342

Merged
Hweinstock merged 2 commits into
aws:mainfrom
Hweinstock:fix/create-dual-telemetry
May 21, 2026
Merged

fix: emit ValidationError instead of UnknownError in create telemetry#1342
Hweinstock merged 2 commits into
aws:mainfrom
Hweinstock:fix/create-dual-telemetry

Conversation

@Hweinstock
Copy link
Copy Markdown
Contributor

Description

When the create command fails validation (e.g. missing --framework, --model-provider, --memory), telemetry emits error_name: "UnknownError" instead of error_name: "ValidationError".

Two root causes:

  1. Plain Error thrown instead of ValidationErrorcommand.tsx throws new Error(validation.error). The classifyError function only recognizes BaseError subclasses via instanceof, so a plain Error gets { category: "UnknownError", source: "unknown" }.

  2. minify: true without keepNames mangles class namesBaseError sets this.name = this.constructor.name. With minification, constructor names are mangled (e.g. "Gr"), so ErrorName.safeParse(err.name) fails for all error subclasses. Per esbuild docs:

    However, minification renames symbols to reduce code size [...] That changes value of the name property for many of these cases. [...] some frameworks rely on the name property for registration and binding purposes. If this is the case, you can enable this option to preserve the original name values even in minified code.

Fix

  • src/cli/commands/create/command.tsx — throw new ValidationError(...) instead of new Error(...)
  • esbuild.config.mjs — add keepNames: true to preserve class names through minification
  • integ-tests/create-edge-cases.test.ts — assert error_name: "ValidationError" and error_source: "user"

Related Issue

Closes #

Type of Change

  • Bug fix

Testing

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@github-actions github-actions Bot added the size/xl PR size: XL label May 21, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@Hweinstock Hweinstock force-pushed the fix/create-dual-telemetry branch from 578088f to ee1869a Compare May 21, 2026 14:20
@github-actions github-actions Bot added size/xs PR size: XS and removed size/xl PR size: XL labels May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Package Tarball

aws-agentcore-0.14.2.tgz

How to install

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

@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

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

@agentcore-devx-automation agentcore-devx-automation Bot added claude-security-reviewing Claude Code /security-review in progress and removed claude-security-reviewing Claude Code /security-review in progress labels May 21, 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 May 21, 2026
Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

The fix correctly identifies both root causes (plain Error vs ValidationError, and minification mangling class names), and keepNames: true is the right global fix that benefits every BaseError subclass.

One concern about completeness: the same throw new Error(validation.error) pattern exists in five other CLI command handlers, all inside runCliCommand blocks where the error feeds directly into classifyError. After this PR they will all still emit error_name: "UnknownError" for validation failures. See the inline comment for details.

Comment thread src/cli/commands/create/command.tsx
@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 21, 2026
@github-actions github-actions Bot added size/s PR size: S and removed size/xs PR size: XS labels May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 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 May 21, 2026
Comment thread src/cli/primitives/GatewayTargetPrimitive.ts
@Hweinstock Hweinstock marked this pull request as ready for review May 21, 2026 15:18
@Hweinstock Hweinstock requested a review from a team May 21, 2026 15:18
@Hweinstock Hweinstock merged commit 0bdc677 into aws:main May 21, 2026
28 of 29 checks passed
@Hweinstock Hweinstock deleted the fix/create-dual-telemetry branch May 21, 2026 16:05
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.

3 participants