fix(errors): use resource not found over input validation for missing resources - #2286
Conversation
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
This is a straightforward, mechanical refactor that reclassifies a set of "resource does not exist" conditions from InputValidationError to the more specific ResourceNotFoundError, with tightened messages.
Confidence-boosters I checked:
ResourceNotFoundError extends InputValidationError(src/errors/errors.tsx:87), so any existinginstanceof InputValidationErrorchecks (e.g.resolveAgentToNameAndIdinsrc/core/eval.tsx:1963) remain valid.- The container test at
src/core/dev/container.test.tswas correctly tightened totoBeInstanceOf(ResourceNotFoundError)for both changed cases. - Grepped for the old message fragments (
"does not exist in credentials[]","container build context directory not found","has no version","the service returned no harness", etc.) — no other tests, snapshots, or callers still depend on them. The one remaining occurrence insrc/projectSchemas/project.ts:292is an unrelated Zod refinement message. - No telemetry instrumentation is warranted; this is a reclassification of existing errors, not a new feature or code path.
Nothing to change. Ship it.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## refactor #2286 +/- ##
=========================================
Coverage 97.06% 97.06%
=========================================
Files 569 569
Lines 39322 39322
=========================================
Hits 38167 38167
Misses 1155 1155 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
notgitika
left a comment
There was a problem hiding this comment.
makes me think if we should invest in something that would help us enforce this.
also, I'm seeing that class ResourceNotFoundError extends InputValidationError I'm not sure I understand this. Can we make the heirarchy better like so:
class UserError extends AgentCoreCLIError
class InputValidationError extends UserError
class ResourceNotFoundError extends UserError
|
Yeah fully agree that is confusing. I think we can rework the structure of the errors to be more normalized. |
Problem
The refactor branch distinguishes malformed input (
InputValidationError) from well-formed input naming an absent resource (ResourceNotFoundError):Ex. already throws
ResourceNotFoundErrorfor lookup misses (e.g.agentcore-cli/src/core/project/manager.tsx
Line 573 in 0caec7f
agentcore-cli/src/core/project/manager.tsx
Line 586 in 0caec7f
InputValidationErrorfor the same "namedentity absent" case
The language is also inconsistent across multiple places.
Solution
Verification