Repository navigation
fix(telemetry): attribute version command runs - #2707
Conversation
Package TarballHow to installgh release download pr-2707-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.0.0.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Reviewed against the PR's base branch (refactor).
The fix is correct and minimal. The pre-parser --version/-V shortcut in Router.route() (src/router/router.tsx:499-507) short-circuits before compile() ever runs, so neither the c.action nor the c.exitOverride call sites of recordCommandPath were reachable — the cli.command_run metric emitted from src/index.ts's finally block had no command_path, which commandPathSchema.catch("unknown") collapsed to "unknown". Recording /${this.cmdName}/version before the CommanderError throw fixes that:
/agentcore/versionsatisfiescommandPathSchema's^\/agentcore(\/[a-z][a-z0-9-]*)*$regex insrc/telemetry/shapes.tsx, so it won't be silently rewritten to"unknown".- There is no real root-level
versionsubcommand (onlyagentcore harness version), so the synthetic path doesn't collide with an existing command path. exit_reasonstays"success"becausesrc/index.tsonly sets"failure"whenerror.exitCode !== 0, and thecommander.versionerror maps to exit 0 — consistent with the test's assertion.
The test uses an in-memory MetricSink (a true I/O boundary) with a real DefaultTelemetryClient, TestGlobalConfigAccessor, and real Router/Commander wiring, and it exercises route() rather than reaching into internals — good. It also preserves the original assertions on the CommanderError shape and exit code.
One non-blocking nit: in src/router/router.test.ts:954, test.each(["--version", "-V"])("$flag on a versioned router ...") uses $-interpolation, which only applies to object rows — with primitive rows the title stays literally $flag, so both cases report the same name. The rest of the repo uses printf style for primitive rows (e.g. src/handlers/project/deploy/index.test.ts:237, src/projectSchemas/aws-targets.test.ts:33), so "%s on a versioned router ..." would make failures identifiable.
Summary
--versionand-Vinvocations as/agentcore/versionbefore the pre-parser exitTesting
bun test src/router/router.test.tsbun run typecheckbun run lint:checkbun run format:checkgit diff --check