-
Notifications
You must be signed in to change notification settings - Fork 20
fix: validate logicalId via diagnostics instead of throwing at construction time [red-71] #1205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sorccu
merged 11 commits into
main
from
michelle/red-71-cli-strip-invalid-characters-from-project-name-in-checkly
Feb 18, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
67437c6
feat: normalize logicalId [red-71]
miliberlin 2d1e992
feat: push test [red-71]
miliberlin 69a89f2
feat: prompt user confirmation for sanitized logicalIds [red-71]
miliberlin 37f35cd
refactor: extract sanitized logicalId confirmation to helper [red-71]
miliberlin f0bc9cd
Merge remote-tracking branch 'origin/main' into michelle/red-71-cli-s…
miliberlin 87da1b8
fix: validate logicalId via diagnostics instead of throwing at constr…
miliberlin f4ae237
fix: restore logicalId property declaration on Project class
miliberlin b0adb3b
Merge branch 'main' into michelle/red-71-cli-strip-invalid-characters…
miliberlin 2dffaa6
fix: update deploy e2e test to use named CheckTypes import
miliberlin fe72a46
fix: address PR review feedback on logicalId validation tests
miliberlin 42a474d
Merge branch 'main' into michelle/red-71-cli-strip-invalid-characters…
sorccu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| const CheckTypes = { | ||
| export const CheckTypes = { | ||
| API: 'API', | ||
| BROWSER: 'BROWSER', | ||
| HEARTBEAT: 'HEARTBEAT', | ||
| MULTI_STEP: 'MULTI_STEP', | ||
| } | ||
|
|
||
| export default CheckTypes | ||
| export const LOGICAL_ID_PATTERN = /^[A-Za-z0-9_\-/#.]+$/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { describe, it, expect, beforeEach } from 'vitest' | ||
|
|
||
| import { Session } from '../project' | ||
| import { Construct } from '../construct' | ||
| import { Diagnostics } from '../diagnostics' | ||
|
|
||
| class TestConstruct extends Construct { | ||
| constructor (logicalId: string) { | ||
| super('test', logicalId) | ||
| } | ||
|
|
||
| describe (): string { | ||
| return `Test:${this.logicalId}` | ||
| } | ||
|
|
||
| synthesize () { | ||
| return null | ||
| } | ||
| } | ||
|
|
||
| describe('Construct logicalId validation', () => { | ||
| beforeEach(() => { | ||
| Session.reset() | ||
| Session.project = { addResource: () => {} } as any | ||
| }) | ||
|
|
||
| it('should pass validation for valid logicalIds', async () => { | ||
| const validIds = ['my-check', 'my_check', 'myCheck123', 'my/check', 'my#check', 'my.check'] | ||
| for (const id of validIds) { | ||
| const construct = new TestConstruct(id) | ||
| const diagnostics = new Diagnostics() | ||
| await construct.validate(diagnostics) | ||
| expect(diagnostics.isFatal(), `Expected "${id}" to be valid`).toBe(false) | ||
| } | ||
| }) | ||
|
|
||
| it('should store the original logicalId without modification', () => { | ||
| const construct = new TestConstruct('my check') | ||
| expect(construct.logicalId).toBe('my check') | ||
| }) | ||
|
|
||
| it('should produce an error diagnostic for logicalIds with spaces', async () => { | ||
| const construct = new TestConstruct('my check') | ||
| const diagnostics = new Diagnostics() | ||
| await construct.validate(diagnostics) | ||
| expect(diagnostics.isFatal()).toBe(true) | ||
| expect(diagnostics.observations).toEqual(expect.arrayContaining([ | ||
| expect.objectContaining({ | ||
| message: expect.stringContaining('contains invalid characters'), | ||
| }), | ||
| ])) | ||
| }) | ||
|
|
||
| it('should produce an error diagnostic for logicalIds with special characters', async () => { | ||
| const construct = new TestConstruct('my@check!') | ||
| const diagnostics = new Diagnostics() | ||
| await construct.validate(diagnostics) | ||
| expect(diagnostics.isFatal()).toBe(true) | ||
miliberlin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(diagnostics.observations).toEqual(expect.arrayContaining([ | ||
| expect.objectContaining({ | ||
| message: expect.stringContaining('contains invalid characters'), | ||
| }), | ||
| ])) | ||
| }) | ||
|
|
||
| it('should produce an error diagnostic for empty logicalIds', async () => { | ||
| const construct = new TestConstruct('') | ||
| const diagnostics = new Diagnostics() | ||
| await construct.validate(diagnostics) | ||
| expect(diagnostics.isFatal()).toBe(true) | ||
miliberlin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(diagnostics.observations).toEqual(expect.arrayContaining([ | ||
| expect.objectContaining({ | ||
| message: expect.stringContaining('contains invalid characters'), | ||
| }), | ||
| ])) | ||
| }) | ||
| }) | ||
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.