fix(codegen): sanitize */ in JSDoc comments to prevent syntax errors#1084
Merged
pyramation merged 1 commit intomainfrom May 9, 2026
Merged
fix(codegen): sanitize */ in JSDoc comments to prevent syntax errors#1084pyramation merged 1 commit intomainfrom
pyramation merged 1 commit intomainfrom
Conversation
When codegen.comments is enabled, field descriptions containing literal */ sequences would prematurely close the JSDoc comment block, producing invalid JavaScript/TypeScript output. Apply the same *\/ sanitization to both babel-ast.ts and hooks-ast.ts addJSDocComment functions, and add unit tests to prevent regression. Closes constructive-io/constructive-planning#820
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
When
codegen.comments: trueis enabled,addJSDocComment()in bothbabel-ast.tsandhooks-ast.tsembeds field descriptions directly into/* ... */block comments without sanitizing. If a description contains a literal*/sequence (common in PostGraphile-generated descriptions like "Reads and enables pagination through a set of ..."), it prematurely closes the JSDoc comment block and produces invalid JavaScript/TypeScript.This PR applies
*/→*\/sanitization to bothaddJSDocCommentimplementations and adds unit tests to prevent regression.Changes:
babel-ast.ts: sanitize*/in lines before building comment texthooks-ast.ts: same sanitization appliedjsdoc-comment.test.ts: 6 tests covering single-line, multi-line, and safe descriptions for both implementationsCloses constructive-io/constructive-planning#820
Review & Testing Checklist for Human
codegen.comments: trueis used with a schema containing*/in field descriptions*\/escape renders acceptably in IDE tooltips and documentation generatorsNotes
The downstream workaround (
comments: falsein constructive-db's codegen-helper.ts) can be reverted once this fix is merged.Link to Devin session: https://app.devin.ai/sessions/2ddfbe8d8fc04675af6e2540decbafe1
Requested by: @pyramation