Conversation
There was a problem hiding this comment.
it would be weird for the user if suddenly the logicalId changes, how about giving a warn on what is going on and what are we going to do? also, they will still have the invalid logicalId on their config right?
There was a problem hiding this comment.
I updated the PR to prompt confirmation and not just overwrite the logicalIds, but yes, the source code will remain unchanged.
Instead of silently sanitizing logicalIds with invalid characters, prompt the user for confirmation before proceeding. This makes it clear what changes will be applied when syncing with Checkly. - Track sanitized logicalIds in Session - Add confirmation prompt in deploy, test, and pw-test commands - Explain that source files won't be modified - Show valid character set to help users fix their config - Fix Project constructor to use sanitized logicalId from Construct Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract the duplicated confirmation prompt code into a reusable helper function to reduce code duplication across deploy, test, and pw-test commands. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
I will write some comments later, please don't merge yet. |
|
@sorccu No worries, I'm not merging this before proper review! I'm a bit skeptical about these changes too. |
…trip-invalid-characters-from-project-name-in-checkly # Conflicts: # packages/cli/src/constructs/project.ts
|
@sorccu what are your thoughts on this? I'm also okay with keeping the previous flow. It's a bit wonky to create a diversion between local code and what we run. We could also just try to make the existing error message a bit more elaborate and keep the error. |
|
I would want to remove the current validation from the constructor and use the validate() method instead. Of course, there are some drawbacks if the construct can store a potentially unclean value, but as long as the validation is error level I think it should be good enough and far better than the current behavior we have. I would rather not interactively ask the user. |
|
If you use the validate method, you can use the hidden validate command to try it out. npx checkly validate |
…uction time Move logicalId character validation from Session.validateCreateConstruct (which threw a hard error at parse time) to Construct.validate() (which reports diagnostics). This lets users see all invalid logicalIds at once instead of fixing them one at a time. Also extracts LOGICAL_ID_PATTERN to constants.ts and converts CheckTypes to a named export. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| export class Project extends Construct { | ||
| name: string | ||
| repoUrl?: string | ||
| logicalId: string |
There was a problem hiding this comment.
Nit: Project.logicalId re-declares and re-assigns the property already defined on the base Construct class. We could remove it to avoid the shadowing, but I kept it for now to minimize changes. Should we clean this up or keep for clarity?
|
@sorccu I updated the approach, can you check? |
…-from-project-name-in-checkly
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sorccu
left a comment
There was a problem hiding this comment.
This still leaves the following two cases uncovered:
- If the
logicalIdis not a string, a hardValidationErrorwill be thrown. - The two resources of the same type have the same logicalId, a hard
ValidationErrorwill be thrown.
We should restructure the code so that soft validation could be used. However, it would make the PR far more complex. The current change is already an improvement over current behavior even if it doesn't cover all cases.
sorccu
left a comment
There was a problem hiding this comment.
Actually, I'd like to see my comments about the tests addressed before this can be merged.
Use expect.arrayContaining/objectContaining/stringContaining pattern in tests instead of checking exact diagnostic types. Remove property name prefix from error message per review nit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Good points. I'll create another ticket for that. Implemented your feedback so far 👍 |
…-from-project-name-in-checkly
Summary
Instead of throwing a hard error at parse time when a logicalId contains invalid characters, we now report it as a validation diagnostic. This means:
No sanitization or interactive prompts — just clear error diagnostics.
Example
Affected Components
Changes
Session.validateCreateConstruct(constructor-time error) toConstruct.validate()(diagnostic)sanitizeLogicalIdand interactive confirmation prompt approachhelpers/sanitized-logical-id.tsLOGICAL_ID_PATTERNtoconstants.tsfor reuseCheckTypesfrom default export to named export