Skip to content

fix(errors): use resource not found over input validation for missing resources - #2286

Merged
jariy17 merged 4 commits into
aws:refactorfrom
Hweinstock:fix/resource-not-found-errors
Sep 11, 2026
Merged

fix(errors): use resource not found over input validation for missing resources#2286
jariy17 merged 4 commits into
aws:refactorfrom
Hweinstock:fix/resource-not-found-errors

Conversation

@Hweinstock

Copy link
Copy Markdown
Contributor

Problem

The refactor branch distinguishes malformed input (InputValidationError) from well-formed input naming an absent resource (ResourceNotFoundError):

Ex. already throws ResourceNotFoundError for lookup misses (e.g.

throw new ResourceNotFoundError(
,
throw new ResourceNotFoundError(
), but several other paths still throw plain InputValidationError for the same "named
entity absent" case

The language is also inconsistent across multiple places.

Solution

  • migrate existing cases.

Verification

  • test-pass, messages updated

@github-actions github-actions Bot added the size/s PR size: S label Sep 11, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Sep 11, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 11, 2026

@agentcore-devx-automation agentcore-devx-automation Bot 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.

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 existing instanceof InputValidationError checks (e.g. resolveAgentToNameAndId in src/core/eval.tsx:1963) remain valid.
  • The container test at src/core/dev/container.test.ts was correctly tightened to toBeInstanceOf(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 in src/projectSchemas/project.ts:292 is 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.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Sep 11, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.06%. Comparing base (4a23516) to head (945b3a5).

Files with missing lines Patch % Lines
src/handlers/project/export/harness.ts 50.00% 1 Missing ⚠️
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.
📢 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 September 11, 2026 19:04

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

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

@Hweinstock

Copy link
Copy Markdown
Contributor Author

Yeah fully agree that is confusing. I think we can rework the structure of the errors to be more normalized.

@jariy17
jariy17 merged commit 7217cfc into aws:refactor Sep 11, 2026
18 of 22 checks passed
@Hweinstock
Hweinstock deleted the fix/resource-not-found-errors branch September 11, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants