[PR #6364] [MERGED] fix(js): resolve literal URL from Request constructor in fetch calls #7310

Closed
opened 2026-11-01 21:46:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6364
Author: @ahmed-husssain
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix/js-fetch-request-url


📝 Commits (2)

  • 0ab7bd0 fix(js): resolve literal URL from Request constructor in fetch calls
  • 884920e fix(js): gate Request URL extraction on fetch and require new operator

📊 Changes

2 files changed (+153 additions, -8 deletions)

View changed files

📝 src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts (+111 -0)
📝 src/domain/javascript/javascriptStaticAnalysisCalls.ts (+42 -8)

📄 Description

Summary

Resolves literal URLs when fetch is invoked with an inline new Request(...) / Request(...) constructor or through an unchanged variable holding a Request instance, fixing #6359.

Fixes #6359

Problem and expected behavior

Prior to this fix, calling fetch(new Request("/api/chat", { method: "POST" })) or const req = new Request("/api/chat"); fetch(req); failed to extract the target URL "/api/chat". Instead, inspectEndpointCall treated any non-literal first argument as dynamic and emitted the full constructor expression as a partial endpoint (value: 'new Request("/api/chat", { method: "POST" })').

Expected behavior is to extract the literal URL string (value: "/api/chat", mechanism: "call:fetch") directly, matching the behavior of fetch("/api/chat", { method: "POST" }).

Change and scope

  • Added requestConstructorUrl helper in src/domain/javascript/javascriptStaticAnalysisCalls.ts that verifies the callee is an unmodified global Request reference and extracts stringValue(arguments[0]).
  • In inspectEndpointCall, resolve the target URL via stringValue(target) ?? requestConstructorUrl(target, bindings).
  • In urlObjectRequestTarget, resolve Request constructor initializers for stable variable bindings and aliases.
  • Added regression tests in src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/javascript/javascriptStaticAnalysisCalls.ts
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing JavaScript static analysis boundary)
  • CLI and MCP/tool-catalog contract: none
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: none
  • Target selection, authority, upstream behavior, and cleanup details: none
  • Generated metadata impact: none

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts
  • Base reproduction: fetch(new Request("/api/chat", { method: "POST" })) failed on base revision by returning resolution: "partial", value: "new Request(\"/api/chat\", { method: \"POST\" })".
  • Remaining proof gaps: none

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:local -- src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts — 18 passed (18)
  • npm run test:local -- src/domain/javascript/javascriptStaticAnalysis.mapEndpoints.test.ts src/domain/javascript/javascriptStaticAnalysis.routeProperties.test.ts src/domain/javascript/javascriptStaticAnalysis.event_source.test.ts src/domain/javascript/javascriptStaticAnalysis.send_beacon.test.ts — 111 passed (111)
  • npm run check:fast — 2 tasks successful (typecheck + lint)

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Author readiness

Human owner: @ahmed-husssain

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/6364 **Author:** [@ahmed-husssain](https://github.com/ahmed-husssain) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/js-fetch-request-url` --- ### 📝 Commits (2) - [`0ab7bd0`](https://github.com/morluto/rea/commit/0ab7bd0e9cf7e398831509c2e55a75e5701fd160) fix(js): resolve literal URL from Request constructor in fetch calls - [`884920e`](https://github.com/morluto/rea/commit/884920ef4b3eadd190915e9c639ae4377a5527fa) fix(js): gate Request URL extraction on fetch and require new operator ### 📊 Changes **2 files changed** (+153 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts` (+111 -0) 📝 `src/domain/javascript/javascriptStaticAnalysisCalls.ts` (+42 -8) </details> ### 📄 Description ## Summary Resolves literal URLs when `fetch` is invoked with an inline `new Request(...)` / `Request(...)` constructor or through an unchanged variable holding a `Request` instance, fixing #6359. Fixes #6359 ## Problem and expected behavior Prior to this fix, calling `fetch(new Request("/api/chat", { method: "POST" }))` or `const req = new Request("/api/chat"); fetch(req);` failed to extract the target URL `"/api/chat"`. Instead, `inspectEndpointCall` treated any non-literal first argument as dynamic and emitted the full constructor expression as a `partial` endpoint (`value: 'new Request("/api/chat", { method: "POST" })'`). Expected behavior is to extract the literal URL string (`value: "/api/chat"`, `mechanism: "call:fetch"`) directly, matching the behavior of `fetch("/api/chat", { method: "POST" })`. ## Change and scope - Added `requestConstructorUrl` helper in `src/domain/javascript/javascriptStaticAnalysisCalls.ts` that verifies the callee is an unmodified global `Request` reference and extracts `stringValue(arguments[0])`. - In `inspectEndpointCall`, resolve the target URL via `stringValue(target) ?? requestConstructorUrl(target, bindings)`. - In `urlObjectRequestTarget`, resolve `Request` constructor initializers for stable variable bindings and aliases. - Added regression tests in `src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts`. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/domain/javascript/javascriptStaticAnalysisCalls.ts` - Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing JavaScript static analysis boundary) - CLI and MCP/tool-catalog contract: none - Provider, bridge, target-format, or platform compatibility: none - Evidence, artifact, provenance, or reconstruction contract: none - Target selection, authority, upstream behavior, and cleanup details: none - Generated metadata impact: none Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts` - Base reproduction: `fetch(new Request("/api/chat", { method: "POST" }))` failed on base revision by returning `resolution: "partial"`, `value: "new Request(\"/api/chat\", { method: \"POST\" })"`. - Remaining proof gaps: none For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts` — 18 passed (18) - `npm run test:local -- src/domain/javascript/javascriptStaticAnalysis.mapEndpoints.test.ts src/domain/javascript/javascriptStaticAnalysis.routeProperties.test.ts src/domain/javascript/javascriptStaticAnalysis.event_source.test.ts src/domain/javascript/javascriptStaticAnalysis.send_beacon.test.ts` — 111 passed (111) - `npm run check:fast` — 2 tasks successful (typecheck + lint) ## Compatibility, safety, and release - Breaking changes or migration steps: none - Real Hopper/Ghidra, browser, or OS coverage: not applicable - Package or release metadata impact: none - Security, privacy, process, or containment review: none ## Author readiness Human owner: @ahmed-husssain - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:46:57 +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#7310
No description provided.