Skip to content

fix(javascript): honor final RPC object properties - #3244

Closed
Vaishnavi220506 wants to merge 1 commit into
morluto:mainfrom
Vaishnavi220506:Vaishnavi220506/fix-rpc-property-ownership
Closed

Vaishnavi220506 wants to merge 1 commit into
morluto:mainfrom
Vaishnavi220506:Vaishnavi220506/fix-rpc-property-ownership

Conversation

@Vaishnavi220506

Copy link
Copy Markdown
Contributor

Summary

Recover RPC endpoint fields from the final known object property, rather than the first literal found. This prevents analyze_javascript_application and 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 later url: runtimeUrl, spread, computed key, getter, or method also leaves the earlier literal incorrectly reported. Precompiled OperationDefinition objects have the same problem for kind, operation, and name.

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

  • Semantic owner and earliest changed stage: RPC recognition in the JavaScript domain; graph consumers reuse its selected facts.
  • Contribution scope fit and linked maintainer decision: existing static analysis correctness; decision not applicable.
  • CLI and MCP/tool-catalog contract: no argument, schema, or catalog changes. RPC endpoint observations now reflect final known fields; overwritten unknown fields produce no stale observation.
  • Provider, bridge, target-format, or platform compatibility: shared source parser; no provider or bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: source ranges and artifact commitments are preserved. No invented runtime URL or operation replaces an unknown field.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged read-only directory/web source analysis with its existing owned parser helper; no added target execution, network access, or resource ownership.
  • Generated metadata, package, or installation impact: none; ignored build artifacts are not committed.

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: 16 property-order cases covering duplicate literals, runtime replacements, spreads, computed keys, accessors/methods, and final explicit properties. Two acceptance cases exercise the built CLI and stdio MCP server on the same authored directory fixture.
  • Base reproduction: the source regression file on 7375ab6e34e511095a74d5a67e57cec28d56fd10 produces 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 local httpBatchLink stub establishes those semantics, not live tRPC library behavior.
  • User-visible CLI/MCP output: the acceptance fixture's endpoint observations include these properties and exclude the three stale URL literals and old GraphQL name:
[
  {"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 --check and pre-commit formatting/lint hooks — pass.

Windows worker supervision used the addon from upstream CI run 38519573909, built at the exact base 7375ab6e3, with node scripts/verify-windows-native-artifact.mjs passing. 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

  • Breaking changes or migration steps: no schema or format migration; corrected RPC observations can differ from previous erroneous results.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows public static-analysis CLI and stdio MCP verified; other providers and live browser workflows not exercised.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: domain selection only; existing static worker supervision and cleanup remain unchanged.

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Changes how RPC endpoint detection reads object properties.

Fix the GraphQL source-body suppression before merging; overwritten text can still be reported as an operation.

Findings

  1. P1 Overwritten GraphQL text returns ▶
  2. P2 Static keys hide endpoints ▶
Fix with agent prompt
### Issue 1
src/domain/javascript/javascriptRpcEndpoints.ts:130-136
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.

### Issue 2
src/domain/javascript/javascriptRpcEndpoints.ts:133-134
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.

Summary

The PR makes RPC object lookups read the final known property and adds source, CLI, and stdio MCP regressions.

  • RPC results now follow the last statically known object property.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Visit object] --> B[Read final known property]
  B --> C[Recover RPC fields]
  B --> D[Hide selected GraphQL body]
  A --> E[Visit every child string]
  E --> F{Selected body?}
  F -->|Yes| G[Skip repeated text]
  F -->|No| H[Read GraphQL operation]
  H --> I[Overwritten body can be reported]
Loading

Reviews (1) · Last reviewed commit: "fix(javascript): honor final RPC object ..." · Reviewed by Greptile

Comment on lines +130 to +136
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;

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.

P1 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.

Comment on lines +133 to +134
const name = semanticStaticPropertyKey(property.key, property.computed);
if (name === null) return undefined;

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.

P2 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.

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.

@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

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.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
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]>
@morluto

morluto commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Superseded by 12b3cdb8041d82e90dc7360db9e74782ac8583ae. RPC extraction now normalizes exact template/bigint keys at the shared AST boundary and retains overwritten GraphQL body literals under their owning object, so superseded values do not reappear as standalone operations. Validation: src/domain/javascript/javascriptRpcEndpoints.test.ts (62 tests, including overwritten/uncertain GraphQL source bodies), passed in the phase-five final log. Static analysis remains limited to recoverable source facts. Thanks to the PR author and reviewers.

@morluto morluto closed this Oct 14, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants