fix(unit-only): DX gap, not a schema defect (the breaking change was inte... (#719)#26
Draft
aidandaly24 wants to merge 4 commits into
Draft
fix(unit-only): DX gap, not a schema defect (the breaking change was inte... (#719)#26aidandaly24 wants to merge 4 commits into
aidandaly24 wants to merge 4 commits into
Conversation
…ws#719) Renames legacy keys at parse time via a Zod preprocess on AgentCoreProjectSpecSchema: top-level `agents` -> `runtimes` (PR aws#706) and credential discriminator `type` -> `authorizerType` (PR aws#709), so pre-v0.4.0 projects keep validating, deploying, and running without manual edits. Mirrors the legacy-aware preprocess in primitives/harness. Refs aws#719
Coverage Report
|
…elemetry - strip the legacy per-runtime `type: "AgentCoreRuntime"` discriminator explicitly in migrateLegacyProjectSpec (robust even if AgentEnvSpecSchema is later tightened to .strict()) and add a test mirroring the issue aws#719 "Before" example verbatim (legacy runtime type + OAuth/Payment credentials) - export AgentCoreProjectSpecBaseSchema so consumers needing ZodObject methods keep access after the z.preprocess wrap; regenerated schema confirmed byte-identical - emit `cli.legacy_project_migrated` telemetry plus a one-time deprecation notice when a pre-v0.4.0 agentcore.json is auto-migrated, wired in the loader via a lib-clean reporter hook so src/lib stays free of CLI/telemetry imports Refs aws#719
…the reporter - the deprecation notice was written to stderr synchronously from the reporter, which during interactive use lands inside the Ink alt-screen buffer and is repainted over (lost to TUI users). Arm a flag in the reporter instead and flush the one-time notice from printPostCommandNotices after the alt-screen is restored, mirroring the existing telemetry/update-notification deferral - add direct unit tests for the CLI reporter module: camelCase->snake_case attr mapping on cli.legacy_project_migrated, the one-time notice latch (exercising the previously-unused resetLegacyProjectMigrationNotice export), the deferred-print contract, and that a TelemetryClientAccessor.get() rejection is swallowed Refs aws#719
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#719
Issues
Root cause
Reproduced live against the v0.20.2 schema. The top-level AgentCoreProjectSpecSchema is .strict() (src/schema/schemas/agentcore-project.ts:564), so the legacy
agentskey produces an unrecognized_keys issue at the root. PR aws#706 renamed agents->runtimes (schema field at agentcore-project.ts:398; confirmed in CHANGELOG.md:647) and PR aws#709 renamed the credential discriminator type->authorizerType (z.discriminatedUnion('authorizerType', ...) at agentcore-project.ts:346). The error flows verbatim: ConfigIO.readProjectSpec (src/lib/schemas/io/config-io.ts:113) -> readAndValidate safeParse (config-io.ts:325) -> ConfigValidationError (src/lib/errors/types.ts:218-225) -> formatZodErrors -> formatZodIssue unrecognized_keys branch "unknown keys (remove)" (src/lib/errors/zod.ts:69-72) -> validate/action.ts formatError (src/cli/commands/validate/action.ts:200). readProjectSpec is the universal gate (27 call sites across commands), so the block is total, not validate-only. There is NO .transform()/preprocess back-compat foragentsand no migrate command (verified by grep; harness.ts has legacy preprocess and payments silently drops the removedpatternkey per agentcore-project.test.ts:442, but agents/credentials got neither). NUANCE correcting the brief: the leftover credentialtypedoes NOT surface as "unknown keys (remove): type" — it surfaces as a discriminated-union failure on the missingauthorizerType(zod.ts:76-78 -> "invalid "authorizerType" value"); and a leftovertypeon a runtime entry is silently stripped (AgentEnvSpecSchema is not .strict()), so removing it is cosmetic, not required.The fix
DX gap, not a schema defect (the breaking change was intentional and announced in CHANGELOG.md:598-604). Best fix: a Zod .preprocess on AgentCoreProjectSpecSchema that auto-renames legacy keys at parse time (agents->runtimes, credential type->authorizerType, strip runtime type) so old projects keep working with zero user action — this mirrors the existing legacy-aware .preprocess pattern in src/schema/schemas/primitives/harness.ts:374. Cheaper alternative: a targeted friendly error mirroring the httpGateways .max(0, '...') deprecation pattern at agentcore-project.ts:545-551, e.g. add an
agentsfield that errors with "The 'agents' field was renamed to 'runtimes' in v0.4.0; rename it and change credential 'type' to 'authorizerType'." At minimum, make the cryptic root message name the rename instead of only living in GitHub issue aws#719. A fullagentcore migratecommand is the heaviest option and likely unnecessary given the migration is 3 deterministic edits.Files touched: src/schema/schemas/agentcore-project.ts (AgentCoreProjectSpecSchema, ~line 390-564): add a .preprocess wrapper that renames legacy keys, OR add an
agentsdeprecation field next to the httpGateways pattern at line 545-551 plus a credential-level hint. Optionally src/cli/commands/validate/action.ts:199 formatError for a targeted upgrade hint, and docs/configuration.md for the written migration guide. No new migrate command exists today. CDK and SDK are NOT touched.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.