Skip to content

fix(errors): define new custom errors for failures. - #1868

Merged
Hweinstock merged 3 commits into
aws:refactorfrom
Hweinstock:fix/type-errors
Jul 29, 2026
Merged

fix(errors): define new custom errors for failures. #1868
Hweinstock merged 3 commits into
aws:refactorfrom
Hweinstock:fix/type-errors

Conversation

@Hweinstock

Copy link
Copy Markdown
Contributor

Problem

There are a few errors that are not yet migrated to the custom errors types. This PR does not aim to migrate all of them, but migrates a few that were raised in a previous PR.

#1848 (comment)

Solution

  • define InputValidationError for when data passed internally fails validation in the config.
  • define invalidEnvironmentError for when tty is missing on stdin and stdout.

Testing

  • updated tests to assert on error type instead of error message.

@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 29, 2026
@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.01%. Comparing base (21353dd) to head (89257cc).
⚠️ Report is 3 commits behind head on refactor.

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #1868   +/-   ##
=========================================
  Coverage     95.00%   95.01%           
=========================================
  Files           161      161           
  Lines          7691     7699    +8     
=========================================
+ Hits           7307     7315    +8     
  Misses          384      384           

☔ 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.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 29, 2026
Comment thread src/globalConfig/accessor.tsx Outdated
}

/** Error raised by invalid data coming from internal sources **/
export class InternalValidationError extends AgentCoreCLIError {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note: I intentionally defined these in the local files since they aren't used elsewhere. I think we can lift these up when we see an opportunity to generalize. I want to avoid lifting this up now, then trying to force these usages elsewhere.

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.

Makes sense to me, that's the only concern I could see from this PR.

@Hweinstock
Hweinstock marked this pull request as ready for review July 29, 2026 21:34
aidandaly24
aidandaly24 previously approved these changes Jul 29, 2026

@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.

Approved, I'd definitely extract the error to the common errors location when we see more use cases.

Comment thread src/globalConfig/accessor.tsx Outdated
Comment on lines +79 to +81
throw new InternalValidationError("failed to validate config data before writing to file", {
cause: dataParseResult.error,
});

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.

One small nit comment, let me know what you think.

This path is reachable from CLI input, not only internal data. I ran agentcore config telemetry '{"enabled":"nope"}'. Then the config handler parses that object and casts it to GlobalConfig, then this logs InternalValidationError with source: "internal". I feel like the handler should probably validate the updated config as user input and throw InputValidationError. Not a blocker or anything but just a thought.

@Hweinstock Hweinstock Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah thats a good point. I think this could be a user or internal error depending on how its reached, but we shouldn't make an internal error so easy to trigger. Also, I ran the same case you described and it produced a worse customer error message so let me actually swap this to InputValidationError. good catch!

jariy17
jariy17 previously approved these changes Jul 29, 2026
@Hweinstock
Hweinstock dismissed stale reviews from jariy17 and aidandaly24 via 89257cc July 29, 2026 22:23
@Hweinstock
Hweinstock merged commit 5b9506f into aws:refactor Jul 29, 2026
8 checks passed
@Hweinstock
Hweinstock deleted the fix/type-errors branch July 29, 2026 23:12
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