Repository navigation
Conversation
An unchanged handler's Route is rebuilt from the route_path and route_method stored on its Function. They were read with a quote scan: an escaped quote or backslash cut the path short, and a nested, broken or non-string value still named a Route. They are now decoded with yyjson, and anything that is not a top-level string that fits names no Route. Every Route and HANDLES properties writer in pass_route_nodes.c now escapes its values into a buffer that fits them: the rebuilt handler QN was unescaped, a QN filling the 512-byte escape buffer left the closing "} off the 512-byte properties, a method is source text where a DRF @action names it, and the SvelteKit +server writer had both problems in 256 bytes. Tests: each of the five new infrascan tests fails on 4cf4414 without this change. Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Review follow-up to the previous commit. Properties hold source text as its bytes, so a Latin-1 docstring stored beside route_path is not UTF-8. The strict yyjson parse rejected that whole object, so the route pass skipped rebuilding the handler's Route, where the old quote scan had rebuilt it. Parse with YYJSON_READ_ALLOW_INVALID_UNICODE, as internal/cbm/diagram.c does. Test: infrascan_decorator_route_metadata_survives_invalid_utf8 fails with the strict parse, and passes with this change and on 4cf4414. Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
app/**/route.{ts,js} files produced 0 Route nodes, so cross-repo
intelligence found no edges into a Next.js backend (DeusData#759).
cbm_extract_nextjs_routes fills route_path/route_method on the
existing Function definition for each exported HTTP-verb handler.
It adds no pass and no synthetic definitions; the route-node pass
builds the Route and HANDLES edge as it does for other frameworks.
CBM_SEMANTIC_INDEX_VERSION goes from 9 to 10 so existing indexes
re-extract once.
Fixes DeusData#759
Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
|
Both failing CI jobs on the latest push look unrelated to this change:
Could you re-run the failed jobs when convenient? #2738, which this PR stacks on, is green. |
What does this PR do?
Fixes #759: Next.js App Router
app/**/route.tshandlers now produce Route nodes and HANDLES edges, so cross-repo intelligence has something to match against. It follows the approach approved in the issue.Stacked on #2738, which makes the route pass read and write route properties as valid JSON. Without it, a route directory with a quote in its name gets a second Route cut at the quote and HANDLES properties that are not valid JSON, on the first full index already (
pipeline_nextjs_quoted_route_round_trip_issue759fails atASSERT(full.read)with the route pass from before #2738). Until #2738 merges, this PR also shows its commits; the change here is the top commit, fa331ed.internal/cbm/extract_nextjs.c(new), called fromcbm.caftercbm_extract_openapi, setsroute_path/route_methodon the existing Function definition. The existing route-node pass then creates the Route nodes and HANDLES edges. It adds no pass, no Variables and no synthetic definitions.export [async] function GET,export const GET[: Type] = [async] (...) => ..., andexport { GET }of such a declaration, inroute.ts/route.jsunderapp/orsrc/app/.sveltekit_route_path):[id]is:id,[...slug]is*slug, a route group(x)adds no segment, and the root route is/. Route nodes carry the handler'sfile_path, sosearch_graph --file-patternfinds them (search_graph: Route nodes have empty file_path, so label=Route + file_pattern always returns 0 — and the hint blames the label #1366).CBM_SEMANTIC_INDEX_VERSION9 → 10, with a history entry, so a v9 index is rebuilt once.Not routed by this increment (each covered by a test)
export const GET = function () {}(the TS/JS extractor makes no Function for it today); renamedexport { h as GET }; re-exports (export { GET } from,export *); destructured or wrapped handlers (auth(handler),as/satisfies); optional catch-all[[...x]]; private_x; parallel@slot; intercepting(.)x; workspace roots (apps/web/app/...);route.tsx/jsx/mjs. Each file is judged on its own, sosrc/app/is routed even where a rootapp/makes Next.js ignore it. HEAD is not derived from GET. Pages Router, Convex and cross-repo matching stay out of scope, as agreed in the issue.Size
+883 / −2: 288 source lines and 595 test lines added. That's over the 500-line guideline because of the lifecycle and upgrade tests; the source alone is under it. I can split the tests out if you'd prefer.
Evidence
Tested on current main (
3457b21b) with #2738 (d9766ae8). Machine: x86_64, 16 cores, WSL2 (Linux 6.18) on Ubuntu 22.04, gcc 11.4; clang-format 20.1.8, cppcheck 2.20.0 and clang-tidy 21.1.8, the versions CI uses.extract_nextjs_route_metadata_contract_issue759extract_nextjs_rejects_nonroutes_issue759pipeline_nextjs_persisted_route_contract_issue759CBM_WORKERS=4,mode=parallelin the log)pipeline_nextjs_persisted_route_contract_parallel_issue759pipeline_nextjs_incremental_lifecycle_issue759pipeline_nextjs_semantic_upgrade_issue759pipeline_nextjs_quoted_route_round_trip_issue759(SKIP_PLATFORMon Windows)CBM_TEST_ONLY, 10 s timeout) in 2.3 s or less; the six fix(pipeline): emit and reconstruct route properties as valid JSON #2738 infrascan tests pass beside them.scripts/test.sh: rc 0, 9918 passed, 0 failed, 9 skipped (SKIP_PLATFORM), 191 suites. Run with step 0w (published language-count contract) removed, because that step fails on main itself; fix(ci): repair language count and Windows CodeQL retrace contracts #2732 fixes it.scripts/lint.sh --ci CLANG_FORMAT=clang-format-20: rc 0, "All linters passed".make -f Makefile.cbm lint-tidy-diff CC=clang-21 CLANG_TIDY=clang-tidy-21on the staged change: rc 0.make -f Makefile.cbm lint-mem-ci CC=clang-21 CLANG_TIDY=clang-tidy-21: rc 0, "memory gate clean".make -f Makefile.cbm security: rc 0, "All security checks passed".cli index_repositorythenquery_graphon HANDLES → Route, isolated cache:examples/cms-contentful(dd904bb7): 2 Routes,GET /api/disable-draftandPOST /api/revalidate, each handled by itsroute.tsFunction (188 nodes, 259 edges); indexing it again unchanged gives the same Routes and counts.pipeline_nextjs_semantic_upgrade_issue759.AI assistance
Implementation and tests were written with AI assistance (Claude Code; planning with Codex). I reviewed the change, ran the commands listed above, and take responsibility for it under my DCO sign-off.
Checklist
git commit -s)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)