Repository navigation
fix(javascript): recover RPC link URLs declared with template literals - #2963
Conversation
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. |
[Medium impact] This PR appears safe to merge. SummaryRecovers constant template-literal RPC URLs through the shared string reader, with unit and CLI/MCP regression coverage.
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 |
|
Compared this PR with main 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: |
7ee4377 to
071db60
Compare
|
Thanks for the review and guidance @morluto! I have rebased the PR onto current
The branch has been force-pushed with a single clean commit ready for review. |
CassieFox23
left a comment
There was a problem hiding this comment.
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 readinesssection. 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,operationandname.valuewritten 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.
🤖 Written with Claude Code (Fable 5.1, verified by Opus 5.5), posted with my OK 🦊
|
Thanks @CassieFox23 for the review! I've updated the PR description to include the Ready for maintainer review whenever you have a moment @morluto. Thanks! |
|
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 🤖 Written with Claude Code (Opus 5.5), posted with my OK 🦊 |
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,trpcLinkUrlextracts theurlproperty usingsemanticFinalObjectStringProperty(options, "url"). Previously,semanticFinalObjectStringPropertystrictly checkedt.isStringLiteral(value).As a result, constant transport URLs declared as expression-free template literals (such as
(0, t.httpLink)({ url:/api/template})orhttpBatchLink({ 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
semanticFinalObjectStringPropertyinsrc/domain/javascript/javascriptAstValues.tsto usereadExactJavaScriptLiteral(value)so that expression-free template literals are resolved to their exact string values without accepting dynamic interpolations or non-string primitives.semanticFinalObjectStringPropertyis a shared helper, constant expression-free template literals also resolve when reading GraphQL operation properties (kind,operation,name.value).src/domain/javascript/javascriptRpcEndpoints.test.tsverifying constant and interpolated template literal link URLs across object-property ownership tables and bundled factory wrappers.tests/acceptance/applications/javascriptRpcPropertyOwnershipCli.test.tsvalidating that template literal RPC options are retained in both CLI and stdio MCP graphs.Contract and boundary impact
src/domain/javascript/javascriptAstValues.ts.x) #2805.trpc:link:*mechanisms.Expected effects:
Evidence and regression coverage
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.{ url:/api/template}link options.For evidence-bearing changes:
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
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
Before merge
type(scope): outcome.x) #2805).