Skip to content

fix(javascript): recover RPC link URLs declared with template literals - #2963

Merged
morluto merged 2 commits into
morluto:mainfrom
ArifAli8866:fix/route-property-template-literals
Nov 18, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
ArifAli8866:fix/route-property-template-literals

Conversation

@ArifAli8866

@ArifAli8866 ArifAli8866 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Recovers tRPC HTTP link URLs whose options are declared with expression-free template literals (e.g. httpLink({ url: /api/template })). Isolates the remaining producer fix and RPC-link regressions from #2805 after route and dynamic-import template handling landed on main in 88afcc7.

Problem and expected behavior

When recovering client-side transport URLs in javascriptRpcEndpoints.ts, trpcLinkUrl extracts the url property using semanticFinalObjectStringProperty(options, "url"). Previously, semanticFinalObjectStringProperty strictly checked t.isStringLiteral(value).

As a result, constant transport URLs declared as expression-free template literals (such as (0, t.httpLink)({ url: /api/template }) or httpBatchLink({ url: /trpc/template })) were dropped rather than captured as network endpoints (trpc:link:<factory>).

Expected behavior: Transport URL options declared as expression-free template literals should be extracted with their exact string value, while dynamic interpolated templates remain unknown.

Change and scope

  • Update semanticFinalObjectStringProperty in src/domain/javascript/javascriptAstValues.ts to use readExactJavaScriptLiteral(value) so that expression-free template literals are resolved to their exact string values without accepting dynamic interpolations or non-string primitives.
  • Note on scope: As semanticFinalObjectStringProperty is a shared helper, constant expression-free template literals also resolve when reading GraphQL operation properties (kind, operation, name.value).
  • Add unit tests in src/domain/javascript/javascriptRpcEndpoints.test.ts verifying constant and interpolated template literal link URLs across object-property ownership tables and bundled factory wrappers.
  • Add regression coverage in tests/acceptance/applications/javascriptRpcPropertyOwnershipCli.test.ts validating that template literal RPC options are retained in both CLI and stdio MCP graphs.

Contract and boundary impact

  • Semantic owner and earliest changed stage: AST inspection in src/domain/javascript/javascriptAstValues.ts.
  • Contribution scope fit and linked maintainer decision: Follows maintainer review on fix(javascript): recover RPC link URLs declared with template literals #2963 to isolate the unmerged RPC link producer fix and regression coverage from [Bug] analyze_web_bundle misses routes declared with template literals (path:x) #2805.
  • CLI and MCP/tool-catalog contract: Unchanged schema; improves recall for constant RPC link endpoints.
  • Provider, bridge, target-format, or platform compatibility: Pure static AST analysis; platform-independent.
  • Evidence, artifact, provenance, or reconstruction contract: Preserves exact coordinates and trpc:link:* mechanisms.
  • Target selection, authority, upstream behavior, and cleanup details: Read-only static AST analysis.
  • 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/javascriptRpcEndpoints.test.ts: Added table test cases covering constant template literals, final overrides, and rejected interpolations in RPC link options, as well as template literal URL recovery in bundled call wrappers.
    • tests/acceptance/applications/javascriptRpcPropertyOwnershipCli.test.ts: Added fixture and assertions verifying template literal link URLs through CLI and stdio MCP analysis.
  • Base reproduction: Base revision dropped { url: /api/template } link options.
  • 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 check:fast — passed (typecheck and lint)
  • npm run format:check — passed (oxfmt)
  • npm run verify:module-boundaries — passed (1928 source files checked)
  • npm run verify:test-discovery — passed (1326 test files verified)
  • npm run test:focused -- src/domain/javascript/javascriptRpcEndpoints.test.ts tests/acceptance/applications/javascriptRpcPropertyOwnershipCli.test.ts — passed (102 tests passed)

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: Pure domain AST analysis.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Pure static analysis; no execution or mutation authority.

Maintainer follow-up

Integrated current main (8a10fa9c00). The shared literal reader preserves the final property owner and recovers exact cooked strings, including escape sequences. Interpolated values remain unknown. The GraphQL regression covers the other consumer of the same property reader.

Four focused cases failed using main’s previous implementation. On the revised head all 138 focused tests passed, including compiled CLI and stdio MCP coverage, along with npm run check:fast, changed-file formatting, and diff checks.

Author readiness

Human owner: @ArifAli8866

  • 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 (Follow-up to [Bug] analyze_web_bundle misses routes declared with template literals (path:x) #2805).
  • 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

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-13T18:16:05.525438Z 7ee4377 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Recovers constant template-literal RPC URLs through the shared string reader, with unit and CLI/MCP regression coverage.

  • JavaScript analysis now reads constant template strings in RPC options.

No actionable issues found. Review was source-based; tests were not rerun.

Reviews (3) · Last reviewed commit: "Merge main and verify exact RPC property..." · Reviewed by Greptile

@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Compared this PR with main fc712b375 during the fixed/superseded backlog audit.

The template route-property and dynamic-import work from #2805 is already on main in 88afcc7, and the narrower duplicate #2823 has been closed.

This PR still contains a distinct missing case: objectStringProperty in javascriptRpcEndpoints only accepts string literals, so an expression-free template used as a tRPC httpLink url is dropped. Please retain and isolate that producer fix and its RPC-link regression when rebasing, and update the title/body around the remaining behavior rather than treating the entire PR as already delivered.

PR head reviewed: 7ee43771e. This is a source comparison; no new PR-branch tests or provider runs were performed for this comment.

@ArifAli8866
ArifAli8866 force-pushed the fix/route-property-template-literals branch from 7ee4377 to 071db60 Compare October 15, 2026 08:34
@ArifAli8866 ArifAli8866 changed the title fix(javascript): recover route properties declared with template literals (#2805) fix(javascript): recover RPC link URLs declared with template literals Oct 15, 2026
@ArifAli8866

Copy link
Copy Markdown
Contributor Author

Thanks for the review and guidance @morluto!

I have rebased the PR onto current main, isolated the change to the unmerged RPC link URL handling, and updated the PR title and description accordingly:

  • Isolated Producer Fix: Updated semanticFinalObjectStringProperty in src/domain/javascript/javascriptAstValues.ts to decode expression-free template literals via readExactJavaScriptLiteral(value), while keeping dynamic interpolations and non-string values dropped.
  • Regression Tests:
    • Added unit tests in src/domain/javascript/javascriptRpcEndpoints.test.ts covering constant template literals, final overrides, rejected interpolations, and bundled call wrappers ((0, t.httpLink)({ url: \/api/template` })`).
    • Added CLI and stdio MCP acceptance coverage in tests/acceptance/applications/javascriptRpcPropertyOwnershipCli.test.ts.
  • Removed the route-property and dynamic-import changes that were already merged into main via 88afcc738.
  • Ran full validation: check:fast, format:check, verify:module-boundaries, verify:test-discovery, and targeted acceptance/unit test suites.

The branch has been force-pushed with a single clean commit ready for review.

@CassieFox23 CassieFox23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR: The fix is still needed: main still drops a tRPC link URL written as a template string. The code is right, but the PR body lacks the Author readiness block the template now requires. The change also reaches the GraphQL reader, which the body does not say.

Findings

Should fix

  • The PR body has no ## Author readiness section. The template gained it on 14 Oct in 90d4098 (#3286), and 5f0065c (#3302) added a check for it. The check wants a "Human owner:" line with one handle and three ticked boxes. No "Validate author declaration" check has run on this head yet, so the gap is not visible on the PR. The next edit or push will trigger it. The template asks a human to fill that block.

Nit

  • The changed helper is also used by the GraphQL reader. So kind, operation and name.value written as template strings now resolve too. The helper also unwraps parentheses and TS casts now. That is fine, but the body scopes the change to tRPC link URLs, and no test covers the GraphQL side. One line in the body, or one table row, would close that.

Looks good

  • Main at 0583fc6 (#6128) still has the old string-literal check at L281, and the link reader still calls it. So the fix is live, not already covered.
  • Dynamic templates stay out. Only a template with no ${} parts and a cooked value is read, and non-string values are dropped. The unit table and the CLI and MCP fixture both pin that.
  • Main changed this file three times since the base. None of those touched this function. GitHub reports the branch as mergeable, and CI on this head is green.
  • Issue #2805 is closed. The comment from morluto here on 15 Oct is the ask for this narrowed fix, and the branch matches it.

Not run

  • No tests or build. This was a code read only.
  • The "102 tests passed" from ArifAli8866 is as reported, not rechecked.
  • CI green on 071db60 is from the GitHub API, not my run.

Thanks, ArifAli8866, for cutting the PR down to the one missing case.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.11
  • Head / base: 071db60 / 6688ed6

🤖 Written with Claude Code (Fable 5.1, verified by Opus 5.5), posted with my OK 🦊

@ArifAli8866

Copy link
Copy Markdown
Contributor Author

Thanks @CassieFox23 for the review!

I've updated the PR description to include the ## Author readiness block (which has now passed the readiness check) as well as the scope note regarding the shared GraphQL reader helper. All CI checks are green with no merge conflicts.

Ready for maintainer review whenever you have a moment @morluto. Thanks!

@CassieFox23

Copy link
Copy Markdown
Contributor

Thanks, ArifAli8866, for the body update. Both of my points are closed. The body now has the Author readiness block, and the PR readiness check passed on it. The scope note now names the GraphQL reader too. The head is still 071db60, so my code read above still holds. Main 015a02d still reads only plain string literals in that helper (line 588 of javascriptAstValues.ts), so the fix is still needed.

🤖 Written with Claude Code (Opus 5.5), posted with my OK 🦊

@morluto
morluto merged commit bba3a3f into morluto:main Nov 18, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants