Skip to content

fix(extract): compose Spring controller route prefixes#772

Open
jonghyunlee-29cm wants to merge 1 commit into
DeusData:mainfrom
jonghyunlee-29cm:fix/spring-kotlin-route-prefix
Open

fix(extract): compose Spring controller route prefixes#772
jonghyunlee-29cm wants to merge 1 commit into
DeusData:mainfrom
jonghyunlee-29cm:fix/spring-kotlin-route-prefix

Conversation

@jonghyunlee-29cm

@jonghyunlee-29cm jonghyunlee-29cm commented Jul 2, 2026

Copy link
Copy Markdown

What does this PR do?

Distilled from a real Spring/Kotlin route-indexing failure: reindexing still missed actual controller API names because Spring method routes were indexed without their class-level @RequestMapping prefix.

Bug/Background

Spring annotation extraction can already produce method-level routes such as /orders, but push_method_def only inspected the method node. Class-level mappings such as @RequestMapping("/api") or Kotlin's @RequestMapping(value = ["/internal/v1/api"]) were not folded into the method route before Route/HANDLES emission.

That leaves the graph with partial Route node names like /orders instead of the actual endpoint /api/orders, which makes API discovery and route search miss the production route shape even though a HANDLES edge exists.

Fix

  • Compose Java/Kotlin class-level Spring mapping prefixes with method-level mapping paths while extracting method definitions.
  • Walk bounded annotation-argument subtrees and choose the first path-shaped string literal, covering named and array-valued annotation arguments while ignoring non-route literals such as media types.
  • Preserve the existing single-route_path extraction model.

Reproduce-first

  • Strengthened the Spring Java edge_types_probe fixture to assert exact Route node names: /api/orders and /api/orders/{id}.
  • Strengthened the Spring Kotlin fixture with @RequestMapping(value = ["/internal/v1/api"]) and exact Route node assertions.
  • Assert the exact Route node set so stale partial routes such as /orders cannot remain alongside the full route.

Validation

  • git diff --check
  • GIT_CONFIG_GLOBAL=/dev/null build/c/test-runner edge_types_probe -> 53 passed
  • GIT_CONFIG_GLOBAL=/dev/null make -f Makefile.cbm test -> 5747 passed
  • GitHub CI lint / lint -> passed (scripts/lint.sh --ci, which provisions cppcheck 2.20.0 and clang-format-20 before running the lint-ci path)

Known limitation

This keeps the existing one-route-per-definition behavior. Multi-path annotations still select the first path-shaped literal rather than expanding into multiple Route nodes.

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects
    unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test (reproduce-first for bug fixes)

@jonghyunlee-29cm jonghyunlee-29cm marked this pull request as ready for review July 2, 2026 15:12
@jonghyunlee-29cm jonghyunlee-29cm force-pushed the fix/spring-kotlin-route-prefix branch from fe005b3 to 7b4a0ee Compare July 2, 2026 15:29
@jonghyunlee-29cm jonghyunlee-29cm marked this pull request as draft July 2, 2026 15:29
Spring class-level RequestMapping prefixes were not folded into method mapping route_path values, so the graph could contain partial Route nodes like /orders instead of the actual endpoint /api/orders even while HANDLES edges existed.

Combine Java/Kotlin class mapping prefixes with method-level mappings during method definition extraction, and scan bounded annotation-argument subtrees so named or array-valued Spring annotations can provide the path literal.

Strengthen edge_types_probe to assert exact Spring Route node names for Java and Kotlin, not just HANDLES edge counts.

Signed-off-by: jonghyun.lee <jonghyun.lee@musinsa.com>
@jonghyunlee-29cm jonghyunlee-29cm force-pushed the fix/spring-kotlin-route-prefix branch from 7b4a0ee to a19fe03 Compare July 3, 2026 01:08
@jonghyunlee-29cm jonghyunlee-29cm marked this pull request as ready for review July 3, 2026 01:08
@jonghyunlee-29cm jonghyunlee-29cm marked this pull request as draft July 3, 2026 01:16
@jonghyunlee-29cm jonghyunlee-29cm marked this pull request as ready for review July 3, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant