fix: resolve URL-builder helper calls to Route/HTTP_CALLS#1010
fix: resolve URL-builder helper calls to Route/HTTP_CALLS#1010CharlesQueiroz wants to merge 3 commits into
Conversation
|
Pushed a follow-up commit: |
9d58769 to
fd03211
Compare
|
Rebased onto the updated #1008 with sign-offs on both commits; no content changes. Full suite passes locally on the stacked branch. |
…#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. Signed-off-by: Charles Queiroz <fcqueiroz@liquibase.com>
) 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. Signed-off-by: Charles Queiroz <fcqueiroz@liquibase.com>
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.
Signed-off-by: Charles Queiroz <fcqueiroz@liquibase.com>
fd03211 to
26c22d0
Compare
|
Rebased the stack onto the updated #1008, which now sits on current main. The only conflict was the adjacent handler registration from another merged PR in extract_unified.c, resolved keeping both. Full suite on the stacked branch: 6360 passed, 1 skipped, 0 failures. lint-format clean. Once #1008 lands this rebases onto main trivially. |
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.