refactor(errors): migrate input validation errors to use the modeled exception. - #1848
refactor(errors): migrate input validation errors to use the modeled exception. #1848Hweinstock wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## refactor #1848 +/- ##
============================================
- Coverage 94.92% 94.90% -0.02%
============================================
Files 155 155
Lines 7565 7615 +50
============================================
+ Hits 7181 7227 +46
- Misses 384 388 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aidandaly24
left a comment
There was a problem hiding this comment.
Couple of comments, let me know what you think.
| const result = flag.schema.safeParse(coerce(flag.schema, opts[attributeName(flag.name)])); | ||
| if (!result.success) { | ||
| throw new TypeError( | ||
| throw new InputValidationError( |
There was a problem hiding this comment.
nit: Could we update the existing invalid-flag router test to assert InputValidationError, matching the new config assertions? It currently checks only the message and passed when this path threw TypeError, so the shared flag-classification change is otherwise untested.
There was a problem hiding this comment.
yeah good call, I like asserting on type rather than message since it avoids coupling with the exact message.
| ); | ||
| } | ||
|
|
||
| const resolver = new SourceResolver({ stdin: io.stdin }); |
There was a problem hiding this comment.
One input-validation path appears to be missing from this migration the SourceResolutionError in src/io/source.ts still extends TypeError. Missing file:// sources and invalid UTF-8 therefore continue to be classified as internal. Could it extend InputValidationError, with a regression test asserting source: "user"? I also get it if you think this is better as a separate PR. I think this may have been because I was working on the SourceResolver at the same time as you were creating the AgentCore Error.
jariy17
left a comment
There was a problem hiding this comment.
Pretty good but u missed:
- accessor.tsx:80
- SourceResolutionError (io/source.ts:13)
- tui/index.tsx:46
Migrated the source resolution, but the other two I think deserve their own errors. agentcore-cli/src/globalConfig/accessor.tsx Lines 76 to 85 in ccd4024 user error.
I also think: agentcore-cli/src/tui/index.tsx Lines 45 to 47 in ccd4024 might be better classified as an error to signify there is something wrong with the users environment rather than that they provided invalid input. However, I do think user error is right here.
I can look into adding custom error types for these two as a follow-up. |
Problem
Follow-up to #1834.
We defined the common errors, but we aren't using the modeled exceptions anywhere.
Solution
Migrate input validation errors to use the shared input validation error.
Notes
Testing
Ran the CLI to verify this error is now classified correctly and logged at the root handler: