Skip to content

fix(javascript): keep recovered invalid templates dynamic in semantic effects - #3815

Merged
kaoru0822-kitauji merged 1 commit into
mainfrom
fix/3361-invalid-template-values
Oct 15, 2026
Merged

kaoru0822-kitauji merged 1 commit into
mainfrom
fix/3361-invalid-template-values

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

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 whose cooked value is null. It then fell back to quasis[0].value.raw. For a template recovered from an invalid escape such as `\unicode`, Babel reports a parse error and cooked: null, so the raw spelling \unicode became a resolved command, endpoint and event name. This contradicts docs/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):

main this PR
spawn(`\unicode`) command "\\unicode", spawns resolved command null, spawns candidate
fetch(`https://example.invalid/\unicode`) endpoint "https://example.invalid/\\unicode", constructs-request resolved endpoint null, constructs-request candidate
.on(`\unicode`, …) event "\\unicode" event null
valid control (program, https://example.invalid/valid, ready) resolved resolved (unchanged)

Real application: Discord app.asar CLI output is identical: normalized JSON, 108,108,885 B both, 15.0 s vs 14.4 s. Output size is unchanged.

Tests:

  • New javascriptSemanticAnalysis.invalid_templates.test.ts: an invalid-escape template yields null command, endpoint and event; a valid template with an escape (`ready\n`) keeps its cooked value "ready\n". It fails on main; I checked by restoring main's helper.
  • 158 JavaScript/domain test files pass (2,969 tests), as does npm run check:fast.

🤖 Generated with Claude Code

… 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]>
@kaoru0822-kitauji kaoru0822-kitauji added the track:perf Performance track PRs (issues & perf loop) label Oct 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T02:51:58.971651Z ac7bb0b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable issues were found.

Summary

Removes the raw-template fallback from dataEffectLiteralString, so recovered templates without a cooked value stay unknown.

  • Invalid template strings stay dynamic in semantic effects.

Reviews (1) · Last reviewed commit: "fix(javascript): keep recovered invalid ..." · Reviewed by Greptile

@kaoru0822-kitauji
kaoru0822-kitauji merged commit 4135c91 into main Oct 15, 2026
33 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/3361-invalid-template-values branch October 15, 2026 03:22
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working track:perf Performance track PRs (issues & perf loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Recovered invalid templates become resolved semantic strings

2 participants