[PR #3815] [MERGED] fix(javascript): keep recovered invalid templates dynamic in semantic effects #5919

Closed
opened 2026-10-31 01:10:26 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3815
Author: @kaoru0822-kitauji
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/3361-invalid-template-values


📝 Commits (1)

  • ac7bb0b fix(javascript): keep recovered invalid templates dynamic in semantic effects

📊 Changes

2 files changed (+45 additions, -4 deletions)

View changed files

➕ src/domain/javascript/javascriptSemanticAnalysis.invalid_templates.test.ts (+38 -0)
📝 src/domain/javascript/javascriptSemanticDataEffectHelpers.ts (+7 -4)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3815 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/3361-invalid-template-values` --- ### 📝 Commits (1) - [`ac7bb0b`](https://github.com/morluto/rea/commit/ac7bb0b8355a43aaf131fdd26843587b6e3449b7) fix(javascript): keep recovered invalid templates dynamic in semantic effects ### 📊 Changes **2 files changed** (+45 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `src/domain/javascript/javascriptSemanticAnalysis.invalid_templates.test.ts` (+38 -0) 📝 `src/domain/javascript/javascriptSemanticDataEffectHelpers.ts` (+7 -4) </details> ### 📄 Description 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:10:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5919
No description provided.