fix(project): validate runtimeVersion on CodeZip runtimes - #1972
Open
notgitika wants to merge 1 commit into
Open
fix(project): validate runtimeVersion on CodeZip runtimes#1972notgitika wants to merge 1 commit into
notgitika wants to merge 1 commit into
Conversation
notgitika
had a problem deploying
to
e2e-testing
August 11, 2026 15:38 — with
GitHub Actions
Failure
notgitika
force-pushed
the
feat/project-build-synth
branch
from
August 11, 2026 19:03
305bf56 to
639227f
Compare
notgitika
force-pushed
the
fix/codezip-runtime-version
branch
from
August 12, 2026 19:54
4c2ac79 to
1ed88a7
Compare
notgitika
had a problem deploying
to
e2e-testing
August 12, 2026 19:54 — with
GitHub Actions
Failure
tejaskash
force-pushed
the
feat/project-build-synth
branch
from
August 12, 2026 20:24
78097a8 to
0b2da99
Compare
notgitika
force-pushed
the
feat/project-build-synth
branch
from
August 13, 2026 15:25
0b2da99 to
05c244e
Compare
notgitika
force-pushed
the
fix/codezip-runtime-version
branch
from
August 13, 2026 15:29
1ed88a7 to
1ac4641
Compare
notgitika
had a problem deploying
to
e2e-testing
August 13, 2026 15:29 — with
GitHub Actions
Failure
The CDK construct library rejects a CodeZip runtime that declares no
runtimeVersion, but our own AgentEnvSpecSchema marked the field plain
`.optional()`. The CLI therefore accepted a spec that synthesis would refuse,
and the user only found out after a compile and a synth.
Mirror the library's rule so the CLI reports it against agentcore.json instead.
Container builds take their version from the image and stay exempt, matching the
adjacent container-only-fields check.
Surfacing the rule earlier is only useful if it says what to fix, and
`resolve()` was collapsing every validation failure into "invalid project
configuration at <path>" with the reasons reachable only from the debug log. It
now renders the failing paths, so the message reads:
invalid project configuration at .../agentcore/agentcore.json
- runtimes[0].runtimeVersion: runtimeVersion is required for CodeZip builds
A JSON syntax error has no zod issues to render and is unchanged.
notgitika
force-pushed
the
fix/codezip-runtime-version
branch
from
August 13, 2026 18:06
1ac4641 to
86d59df
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #1972 +/- ##
=========================================
Coverage 96.91% 96.91%
=========================================
Files 356 356
Lines 20136 20159 +23
=========================================
+ Hits 19515 19538 +23
Misses 621 621 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
typecheck failing on refactor head and therefore also on this PR |
tejaskash
approved these changes
Aug 13, 2026
Hweinstock
reviewed
Aug 13, 2026
| * Without this the cause is only reachable from the debug log, leaving the user with | ||
| * "invalid project configuration" and no indication of which field to fix. | ||
| */ | ||
| function describeValidationFailure(cause: unknown): string { |
Contributor
There was a problem hiding this comment.
would z.prettifyError help us here? https://zod.dev/error-formatting
| @@ -63,9 +86,10 @@ export class FsProjectManager implements ProjectManager { | |||
| } catch (error) { | |||
Contributor
There was a problem hiding this comment.
would it be easier to drop this try/catch and update the error in
Line 55 in ea3fa84
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.
Stacked on #1970 (itself on #1969) — review those first. Follows up on the second commit of #1970, which set
runtimeVersionon the python template; this makes the CLI able to catch the same class of error itself.The gap
The CDK construct library's
AgentEnvSpecSchemarefines:Our copy of that schema marked the field plain
.optional(), with no such rule. So the CLI accepted a spec that synthesis would refuse, and the user only discovered it after a fulltsc+cdk synth— from a stack trace inside the generated app rather than from the CLI.Our
superRefinealready mirrors the library's checks almost one for one, including the identical container-only-fields loop directly beneath. This adds the one that was missing, in the same position the library has it:Container builds take their version from the image and stay exempt, consistent with the check below it.
Reporting the rule earlier is only useful if it says what to fix
Moving the error earlier initially made it worse, which is worth calling out because it's the larger half of this diff.
FsProjectManager.resolvewas collapsing every validation failure into one line:The zod issues were attached as
cause, which nothing renders — they were reachable only from the debug log. So the user traded CDK's preciseruntimes[0].runtimeVersion: runtimeVersion is required for CodeZip buildsfor a message that doesn't name a field.resolve()now renders the failing paths:That's every validation failure of
agentcore.json, not just this one — any spec error now names its field. A JSON syntax error carries no zod issues, so that path is unchanged and still covered by its existing test.Blast radius
ProjectSpecSchemahas exactly one consumer:resolve()atmanager.tsx:56. So the only configs this newly rejects are ones the CDK app would also reject at synth — no workflow that previously succeeded starts failing. It does mean the whole CLI now refuses to load such a config rather than failing at build time, which is the intent.Two test fixtures were CodeZip runtimes without
runtimeVersionand are now invalid by this rule, so they gain one (schema/runtime.test.ts,schema/project.test.ts). Worth a look during review that the surrounding assertions still test what they claim — the security-group-cap test atruntime.test.tsasserts a CodeZip spec succeeds, so it would have silently started passing for the wrong reason had the fixture not been fixed.Verification
Against the same real scaffolded project used to verify #1970, with
runtimeVersionremoved from itsagentcore.json:tscran,cdk synthran, then the construct library's zod error.runtimes[0].runtimeVersion: runtimeVersion is required for CodeZip builds— no compile, no synth, nonode_modulesneeded.New unit tests: the rule rejects a CodeZip runtime with no
runtimeVersionand reports it atpath: ["runtimeVersion"]; a container runtime without one still validates; andresolve()surfaces the field name in its message.bun test— 1063 pass, 0 failtsc --noEmitclean,oxlintclean