fix: convert remaining hard errors to soft diagnostics for logicalId validation [red-00]#1226
Open
miliberlin wants to merge 4 commits intomainfrom
Open
fix: convert remaining hard errors to soft diagnostics for logicalId validation [red-00]#1226miliberlin wants to merge 4 commits intomainfrom
miliberlin wants to merge 4 commits intomainfrom
Conversation
…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
commented
Feb 18, 2026
| } | ||
|
|
||
| throw new Error(`Resource of type '${type}' with logical id '${logicalId}' already exists.`) | ||
| this.duplicateResources.push({ type, logicalId }) |
Member
Author
There was a problem hiding this comment.
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
…logicalId Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
logicalIdnow coerces to string and reports a diagnostic instead of throwing a hardValidationErrorlogicalIdnow tracks duplicates and reports diagnostics instead of throwing, so all errors are surfaced togetherFollow-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:
Test plan
npx tsc --noEmitpassesnpx vitest --run src/constructs/__tests__/project.spec.ts— 7 tests passnpx checkly testconfirms all diagnostics reported together🤖 Generated with Claude Code