Skip to content

fix: convert remaining hard errors to soft diagnostics for logicalId validation [red-00]#1226

Open
miliberlin wants to merge 4 commits intomainfrom
michelle/red-71-soft-diagnostics-for-logicalid-validation
Open

fix: convert remaining hard errors to soft diagnostics for logicalId validation [red-00]#1226
miliberlin wants to merge 4 commits intomainfrom
michelle/red-71-soft-diagnostics-for-logicalid-validation

Conversation

@miliberlin
Copy link
Member

@miliberlin miliberlin commented Feb 18, 2026

Summary

  • Non-string logicalId now coerces to string and reports a diagnostic instead of throwing a hard ValidationError
  • Duplicate logicalId now tracks duplicates and reports diagnostics instead of throwing, so all errors are surfaced together
  • Updates existing "should throw" tests to verify diagnostics instead

Follow-up to #1205, addressing sorccu's review comment about converting the two remaining hard error cases to soft diagnostics.

Example output

All validation errors are now reported together instead of stopping on the first one:

Parsing your project... ✅

Validating project resources... ❌
✖ Invalid property value

  The value provided for property "logicalId" is not valid.

  Reason: "boilerplate project (invalid)" contains invalid characters. Only
  A-Z, a-z, 0-9, _, -, /, #, and . are allowed.

✖ Invalid property value

  The value provided for property "logicalId" is not valid.

  Reason: A check with logicalId "duplicate-check-id" already exists.

✖ Invalid property value

  The value provided for property "logicalId" is not valid.

  Reason: A check-group with logicalId "duplicate-group-id" already exists.

✖ [ApiCheck:123] Invalid property value

  The value provided for property "logicalId" is not valid.

  Reason: Expected a string but received type "number".

✖ [ApiCheck:books api check (v1)] Invalid property value

  The value provided for property "logicalId" is not valid.

  Reason: "books api check (v1)" contains invalid characters. Only A-Z, a-z,
  0-9, _, -, /, #, and . are allowed.


✖ Unable to continue due to unresolved validation errors.

Test plan

  • npx tsc --noEmit passes
  • npx vitest --run src/constructs/__tests__/project.spec.ts — 7 tests pass
  • Full test suite passes (excluding pre-existing playwright-check failures)
  • Manual e2e test with npx checkly test confirms all diagnostics reported together

🤖 Generated with Claude Code

…validation [red-71]

Non-string logicalId and duplicate logicalId errors were still thrown as
hard errors during construct construction, stopping on the first error.
Convert both to soft diagnostics so all issues are reported together.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@miliberlin miliberlin changed the title fix: convert remaining hard errors to soft diagnostics for logicalId validation [red-71] fix: convert remaining hard errors to soft diagnostics for logicalId validation [red-00] Feb 18, 2026
}

throw new Error(`Resource of type '${type}' with logical id '${logicalId}' already exists.`)
this.duplicateResources.push({ type, logicalId })
Copy link
Member Author

Choose a reason for hiding this comment

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

The first resource with a given logicalId gets stored normally in this.data, and only the second (and any subsequent) duplicate gets pushed to duplicateResources. So the diagnostic says "already exists" pointing at the duplicate, not the first occurance.

I think this is a reasonable behaviour, but if you'd prefer to flag both (so the user can see which two are clashing), we could change the approach. Wdyt? @sorccu

@miliberlin miliberlin requested a review from sorccu February 18, 2026 12:09
@miliberlin miliberlin marked this pull request as ready for review February 18, 2026 12:09
@miliberlin
Copy link
Member Author

Fixing the tests

Soft diagnostics are printed via log() to stdout, not stderr.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant

Comments