Repository navigation
fix(javascript): honor final RPC object properties - #3244
Vaishnavi220506 wants to merge 1 commit into
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
| for (let index = node.properties.length - 1; index >= 0; index -= 1) { | ||
| const property = node.properties[index]; | ||
| if (property === undefined || t.isSpreadElement(property)) return undefined; | ||
| const name = semanticStaticPropertyKey(property.key, property.computed); | ||
| if (name === null) return undefined; | ||
| if (name === key) | ||
| return t.isObjectProperty(property) ? property.value : undefined; |
There was a problem hiding this comment.
Overwritten GraphQL text returns
For { body: "query Old { user }", body: "query Current { user }", locationOffset: { line: 1, column: 1 } }, the new objectProperty lookup selects Current. The caller adds only that string to documentSourceBodies, so the later string scan reports the overwritten Old as an endpoint. A trailing spread also leaves the old body reportable.
Suppress all source-body literals in these objects, not just the selected value, so overwritten text cannot become a separate endpoint.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptRpcEndpoints.ts
Line: 130-136
Comment:
**Overwritten GraphQL text returns**
For `{ body: "query Old { user }", body: "query Current { user }", locationOffset: { line: 1, column: 1 } }`, the new `objectProperty` lookup selects `Current`. The caller adds only that string to `documentSourceBodies`, so the later string scan reports the overwritten `Old` as an endpoint. A trailing spread also leaves the old body reportable.
Suppress all source-body literals in these objects, not just the selected value, so overwritten text cannot become a separate endpoint.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const name = semanticStaticPropertyKey(property.key, property.computed); | ||
| if (name === null) return undefined; |
There was a problem hiding this comment.
The new name === null stop treats unsupported static keys as possible writes to every field. semanticStaticPropertyKey does not recognize template literals or bigint keys, so httpBatchLink({ url: "/trpc/live", [headers]: {} }) now loses its URL even though the later key cannot replace url.
Recognize these exact keys before treating a property as an unknown write, and add regression cases for unrelated static keys.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptRpcEndpoints.ts
Line: 133-134
Comment:
**Static keys hide endpoints**
The new `name === null` stop treats unsupported static keys as possible writes to every field. `semanticStaticPropertyKey` does not recognize template literals or bigint keys, so `httpBatchLink({ url: "/trpc/live", [`headers`]: {} })` now loses its URL even though the later key cannot replace `url`.
Recognize these exact keys before treating a property as an unknown write, and add regression cases for unrelated static keys.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
CI-fix track: this change is already on main via b8eea78 ("honor final RPC object properties", co-authored by you). Merging current main into this branch yields a tree identical to main, so there's nothing left to push. The failing shard and Portable jobs reflected main's state during that run. This PR looks safe to close as superseded. |
Normalize exact template and bigint keys at the shared AST boundary. Keep overwritten GraphQL body literals owned by their source object so they cannot resurface as standalone operations. Reviewed-PR: #3244 Co-authored-by: Vaishnavi220506 <[email protected]>
|
Superseded by |
Summary
Recover RPC endpoint fields from the final known object property, rather than the first literal found. This prevents
analyze_javascript_applicationand the shared web bundle analyzer from reporting an obsolete tRPC URL or an overwritten GraphQL operation name/type.Problem and expected behavior
For
httpBatchLink({ url: "/trpc/old", url: "/trpc/live" }), JavaScript supplies/trpc/live, but REA reports/trpc/old. A laterurl: runtimeUrl, spread, computed key, getter, or method also leaves the earlier literal incorrectly reported. PrecompiledOperationDefinitionobjects have the same problem forkind,operation, andname.Expected: use the final statically known definition; when a later property could replace it with an unknown value, omit the stale literal. An explicit final property after a spread or dynamic key remains recognizable. This is a source-discovered bug with an executable fixture reproduction; no issue was supplied.
Change and scope
Make the existing object-property lookup the single owner of property selection for RPC recognition. Scan from the final definition, stop at unknown writes/accessors/methods, and let the string lookup consume that selected node. Document this behavior and add source and public CLI/stdio MCP regressions.
This is an ordinary correctness fix within the existing contribution scope; an advance maintainer scope decision is not applicable. This does not add spread evaluation or execute analyzed application code.
Contract and boundary impact
Expected effects:
Evidence and regression coverage
7375ab6e34e511095a74d5a67e57cec28d56fd10produces 14 failures and 38 passes. With the fix, all 52 pass. A Node.js control in each acceptance case verifies actual object construction semantics; its localhttpBatchLinkstub establishes those semantics, not live tRPC library behavior.[ {"value":"/trpc/live","mechanism":"trpc:link:httpBatchLink"}, {"value":"/trpc/final","mechanism":"trpc:link:httpBatchLink"}, {"value":"Current","mechanism":"graphql:mutation"} ]Remaining proof gaps: no live tRPC server/client, browser capture, or analyzed application execution. The full repository test suite was not run.
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
Node 24.18.0 / npm 11.16.0 on Windows, HEAD
1c57b56559f1cad061f54254007b73c7e395ce86:npm run test:focused -- src/domain/javascript/javascriptRpcEndpoints.test.ts tests/acceptance/applications/javascriptRpcPropertyOwnershipCli.test.ts src/domain/webBundleAnalyzer.test.ts src/domain/webBundleAnalyzerAst.test.ts— 90 pass, including built CLI, stdio MCP, and neighboring web bundle analysis.npm run check— passes.npm run verify:test-discovery— all 1,247 test files discovered exactly once.npm run docs:check— passes, including five README consistency tests.git diff --checkand pre-commit formatting/lint hooks — pass.Windows worker supervision used the addon from upstream CI run 38519573909, built at the exact base
7375ab6e3, withnode scripts/verify-windows-native-artifact.mjspassing. The checkout initially lacked the addon, and the published 6.4.0 addon lacked a current required capability; those unavailable-provider attempts were resolved before the passing acceptance run.Compatibility, safety, and release
Before merge
type(scope): outcome.