fix: resolve URL-builder helper calls to Route/HTTP_CALLS#1010
Open
CharlesQueiroz wants to merge 3 commits into
Open
fix: resolve URL-builder helper calls to Route/HTTP_CALLS#1010CharlesQueiroz wants to merge 3 commits into
CharlesQueiroz wants to merge 3 commits into
Conversation
…#1006) Client-side URL extraction only recognized static string literals; any template literal was silently skipped, so parameterized endpoints never produced HTTP_CALLS edges or Route nodes and cross-repo route matching missed them (the server side already normalizes path params to {}). New cbm_template_string_text() flattens a template_string node: string fragments verbatim, each ${...} substitution becomes {}. Wired into: - extract_positional_url / extract_string_value (call-arg URLs) - handle_string_refs (URL-shaped refs from const/return positions) - handle_string_constants (module-level const lookups) `/api/v1/things/${id}` now yields __route__ANY__/api/v1/things/{} and the enclosing function gets the HTTP_CALLS edge, joining the canonical placeholder shape of server-side routes.
) URL-shaped literals returned from small builder functions never reached call arguments, so client(buildPath(id)) produced no HTTP_CALLS edge and no Route node, static or template alike. handle_url_builders() records builderName -> returned URL in the same per-file constant map used for module-level consts, covering return statements and arrow expression bodies; a call_expression branch in extract_url_or_topic_arg() resolves client(buildPath(id)) through it. Composed builders inline already-recorded substitutions and truncate the query string, so `${basePath(id)}?${params}` joins the server route exactly. Ambiguous builders (two different URLs) are tombstoned.
detect_url_in_args() (the arg_url HTTP_CALLS emitter used when the callee
is a local client wrapper, not a known HTTP library) reads per-arg values,
not first_string_arg. Resolve call_expression args through the builder map
and flatten template_string args to the {} form there as well, so wrappers
like apiFetch(buildPath(id)) emit the edge and join the canonical route.
Author
|
Pushed a follow-up commit: |
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1009. Stacked on #1008 (includes its commit; rebases cleanly once #1008 lands).
Root cause
URL-shaped literals returned from small builder functions never reach a call argument, so
client(buildPath(id))had nofirst_string_arg: no HTTP_CALLS edge, no Route node, static and template literals alike.lookup_string_constantonly covers module-level consts.Fix
handle_url_builders()(extract_unified.c, runs in the unified walk): when areturnstatement (or an arrow-function expression body) yields a URL-shaped literal, recordsbuilderName -> urlin the same per-file constant map used for module-level consts. Ambiguous builders (two different URLs for one name) are tombstoned so lookups miss instead of guessing.extract_url_or_topic_arg()(extract_calls.c): acall_expressionargument whose callee is a plain identifier resolves through that map, giving the call itsfirst_string_arg; the existing pipeline then mints the Route node and the HTTP_CALLS edge from the real HTTP caller (the hook), not from the builder.${...}substitution that is a bare identifier or a call to an already-recorded name inlines that value, everything else becomes{}, and the result is truncated at the first?(query strings are not part of a route's identity). This covers the real-world TanStack shape:Same-file scope, document order (same constraints the const map already has).
Validation
extract_ts_url_builder_issue1009(return + arrow bodies) andextract_ts_url_builder_composed_issue1009(composition + query truncation).queryFn -HTTP_CALLS-> /api/v1/team-members/{}/activitynow exists for the builder shape, joining the server-side__route__GET__/api/v1/team-members/{}/activityexactly.