Skip to content

fix(project): simplify agentcore spec serialization errors - #2031

Merged
notgitika merged 3 commits into
aws:refactorfrom
Hweinstock:fix/avoid-writing-corrupted-config
Aug 18, 2026
Merged

fix(project): simplify agentcore spec serialization errors#2031
notgitika merged 3 commits into
aws:refactorfrom
Hweinstock:fix/avoid-writing-corrupted-config

Conversation

@Hweinstock

@Hweinstock Hweinstock commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Problem

This PR solves two related problems with project spec serialization.

  • the agentcore spec is not validated before writing out. The harness piece is already validated as a side-effect of scaffolding, but we should validate the whole config.
  • DeserializationError does not extend the base error. (think it preceded it)

Solution

  • validate entire agentcore spec before writing out.
  • make deserialization error a user error to avoid rewrapping.

Testing

added a unit test to verify the case by corrupting the agentcore.json and validating we fail early.

@Hweinstock Hweinstock changed the title Fix/avoid writing corrupted config fix(project): simplify agentcore spec serialization errors Aug 18, 2026
@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Aug 18, 2026
@codecov-commenter

codecov-commenter commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.09%. Comparing base (2e18071) to head (3257f9a).
⚠️ Report is 1 commits behind head on refactor.

Additional details and impacted files
@@             Coverage Diff              @@
##           refactor    #2031      +/-   ##
============================================
- Coverage     97.09%   97.09%   -0.01%     
============================================
  Files           381      381              
  Lines         22778    22774       -4     
============================================
- Hits          22116    22112       -4     
  Misses          662      662              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Hweinstock
Hweinstock marked this pull request as ready for review August 18, 2026 22:29
@Hweinstock
Hweinstock marked this pull request as draft August 18, 2026 22:33
@Hweinstock
Hweinstock force-pushed the fix/avoid-writing-corrupted-config branch from f261c3d to 3257f9a Compare August 18, 2026 22:42
@Hweinstock
Hweinstock marked this pull request as ready for review August 18, 2026 22:45

@aidandaly24 aidandaly24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good to me

Comment on lines -66 to +70
try {
const spec = await this.json.read(configPath, ProjectSpecSchema);
return {
name: spec.name,
rootPath,
spec,
};
} catch (error) {
// A malformed agentcore.json is a user-correctable problem, not a crash.
if (error instanceof DeserializationError) {
throw new InputValidationError(`invalid project configuration at ${configPath}`, {
cause: error,
});
}
throw error;
}
const spec = await this.json.read(configPath, ProjectSpecSchema);
return {
name: spec.name,
rootPath,
spec,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verrry nice👌

@notgitika notgitika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks LGTM!

@notgitika
notgitika merged commit 1a21206 into aws:refactor Aug 18, 2026
8 of 11 checks passed
@Hweinstock
Hweinstock deleted the fix/avoid-writing-corrupted-config branch August 18, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants