Skip to content

JS/TS: fetch/axios URLs built from template literals over module-level constants are not extracted as HTTP_CALLS #1147

Description

@paolo-blocklabs

Version

main @ e678b2b (v0.9.0-221)

Platform

macOS (Apple Silicon)

Install channel

GitHub release archive / install.sh / install.ps1

Binary variant

standard

What happened, and what did you expect?

In a production Next.js/React 19 monorepo (pnpm workspaces, ~2,800 nodes indexed), the graph contains only 10 HTTP_CALLS edges — all literal page paths from tests (/en-gb/slots, /games/list, …). None of the application's actual API calls are extracted, because every endpoint is a template literal composed from module-level string constants.

With the callee side now minting Route nodes correctly (#1059), this caller-side gap is the last blocker for CROSS_HTTP_CALLS: the linking pass still produces zero edges fleet-wide. Possibly related to the native-fetch under-extraction tracked in #856 / #706, but this is specifically about template-literal URL composition.

Suggested handling (in increasing order of ambition)

  1. Constant folding of template literals: when every ${...} part of a template literal resolves (within the module, or via an imported const) to a compile-time string, fold and extract the result. `${BASE}/users/me` with const BASE = 'api'api/users/me. This alone covers the central-endpoints-map idiom below — the most common frontend pattern we know of.
  2. Imported-constant resolution at the call site: fetch(API_ENDPOINTS.USER) / client.post(API_ENDPOINTS.GAME_LAUNCH_URL, ...) — resolve the member access to the folded constant from step 1 across module boundaries.
  3. Unresolvable-prefix canonicalization: when a leading ${...} can't be folded (e.g. ${getApiBaseUrl()}), mint the edge with the resolvable suffix (/api/users/me) and mark the prefix as dynamic (property url_prefix_dynamic: true), so cross-repo matching can still suffix-match against Route identities.

Steps 1+2 would take our monorepo from 0 extracted API calls to full coverage of the endpoints table; step 3 covers the wrapper-client pattern generically.

Environment

Next.js / React 19 micro-frontends, pnpm workspaces; calls via native fetch and a thin axios-style wrapper. Built from source on Linux x86_64, gcc, make -f Makefile.cbm cbm.

Reproduction

  1. Code: dummy snippet (mirrors our real endpoint-constants module + call sites):

endpoints.ts:

const BASE = 'api'
export const API_ENDPOINTS = {
  LOGIN: `${BASE}/users/login`,
  USER: `${BASE}/users/me`,
  GAME_LAUNCH_URL: `${BASE}/games/launch`,
}
export const getApiBaseUrl = () => `${API_PROTOCOL}://${process.env.API_DOMAIN}/`

client.ts:

import { API_ENDPOINTS, getApiBaseUrl } from './endpoints'
const response = await fetch(`${getApiBaseUrl()}/${API_ENDPOINTS.USER}`, { method: 'GET' })
const result = await apiClient.post(API_ENDPOINTS.GAME_LAUNCH_URL, payload)
  1. Command: codebase-memory-mcp cli index_repository --repo-path . then
    codebase-memory-mcp cli query_graph with MATCH ()-[r:HTTP_CALLS]->() RETURN r.url_path

  2. Result: no HTTP_CALLS edge for any of these call sites (only unrelated literal-string paths from tests are minted) / Expected: edges with url_path api/users/me, api/games/launch (or suffix-canonicalized equivalents)

Logs


Diagnostics trajectory (memory / performance / leak issues)


Project scale (if relevant)

2,845 nodes / 5,476 edges (Next.js pnpm-workspaces monorepo)

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.ux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions