Repository navigation
fix(javascript): keep recovered invalid templates dynamic in semantic effects - #3815
Conversation
… effects dataEffectLiteralString asked the literal owner for an exact value, and when a template recovered with an invalid escape had no cooked value it fell back to the raw spelling. Child-process commands, request endpoints and event names then became resolved values that are not JavaScript strings. Use only the owner's cooked value; a template without one stays dynamic. Fixes #3361 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] This PR appears safe to merge; no actionable issues were found. SummaryRemoves the raw-template fallback from
Reviews (1) · Last reviewed commit: "fix(javascript): keep recovered invalid ..." · Reviewed by Greptile |
Fixes #3361
Root cause
dataEffectLiteralString(javascriptSemanticDataEffectHelpers.ts) reads the static string argument for semantic data effects: child-process commands, request endpoints and event names. It first asks the literal owner,readExactJavaScriptLiteral, which already returns nothing for a template whosecookedvalue isnull. It then fell back toquasis[0].value.raw. For a template recovered from an invalid escape such as`\unicode`, Babel reports a parse error andcooked: null, so the raw spelling\unicodebecame a resolved command, endpoint and event name. This contradictsdocs/javascript-artifact-reconstruction.md("a template recovered with a parser error and no cooked value stays dynamic").Change
The raw fallback is removed. The helper now returns only the owner's exact (cooked) value, so a template without one stays dynamic. Valid templates are unaffected: the owner already returned their cooked value, including escapes, before the fallback was reached.
Validation
The issue's repro (public CLI,
semantic_graph):mainspawn(`\unicode`)"\\unicode",spawnsresolvednull,spawnscandidatefetch(`https://example.invalid/\unicode`)"https://example.invalid/\\unicode",constructs-requestresolvednull,constructs-requestcandidate.on(`\unicode`, …)"\\unicode"nullprogram,https://example.invalid/valid,ready)Real application: Discord
app.asarCLI output is identical: normalized JSON, 108,108,885 B both, 15.0 s vs 14.4 s. Output size is unchanged.Tests:
javascriptSemanticAnalysis.invalid_templates.test.ts: an invalid-escape template yieldsnullcommand, endpoint and event; a valid template with an escape (`ready\n`) keeps its cooked value"ready\n". It fails onmain; I checked by restoring main's helper.npm run check:fast.🤖 Generated with Claude Code