Skip to content

Java/Spring: class-level @RequestMapping prefix dropped from Route nodes — breaks cross-repo-intelligence for prefixed controllers #734

Description

@maehrlae2

Version: v0.8.1 (Windows amd64)

Summary

For Spring MVC/Boot REST controllers that put a base path on the class via @RequestMapping("/prefix") and per-endpoint paths on @GetMapping/@PostMapping/etc., the extracted Route node only stores the method-level path fragment — the class-level prefix is silently dropped. Every Route in the graph ends up with the wrong (truncated) path, so cross-repo-intelligence can never produce a CROSS_HTTP_CALLS edge for these routes: the caller's real URL (which does include the prefix) can never string-match the truncated route.

Repro

@RestController
@RequestMapping("/api/corporate/mcc")
public class MccRequirementController {

    @GetMapping("/corporates/{corporateId}/requirements")
    public ResponseEntity<?> getCorporateRequirements(@PathVariable long corporateId) { ... }
}

Expected Route: GET /api/corporate/mcc/corporates/{corporateId}/requirements
Actual Route in the graph (via search_graph(label="Route", name_pattern=".*mcc.*")): GET /corporates/{corporateId}/requirements — the /api/corporate/mcc prefix is missing.

Not an isolated case: on a real ~45k-node Spring Boot codebase, sampling all 120 extracted Route nodes, none carry their controller's class-level @RequestMapping prefix, across several distinct controllers/base paths.

Impact

index_repository(mode="cross-repo-intelligence") against a real consumer (a Laravel/PHP frontend calling these Java REST endpoints over HTTP with fully-qualified, correct paths) returns total_cross_edges: 0 for every category — consistent with #523, #678, #686, which look like the same underlying bug class (router/class-level prefix stripped) across different frameworks (FastAPI, Go Fiber). This appears to be the Java/Spring instance of that same class of bug, which I didn't see filed separately.

Environment

  • OS: Windows 11
  • codebase-memory-mcp: v0.8.1
  • Language: Java 23 / Spring Boot 3.5.5, @RestController + class-level @RequestMapping + method-level @GetMapping/@PostMapping/etc.

Activity

  1. added
    bugSomething isn't working
    parsing/qualityGraph extraction bugs, false positives, missing edges
    priority/normalStandard review queue; useful PR with ordinary maintainer urgency.
    on Jul 1, 2026
  2. DeusData commented on Jul 1, 2026

    @DeusData
    Owner

    Thanks, this is a good actionable Java/Spring route extraction bug. Class-level @RequestMapping prefixes should compose with method-level mappings before we emit Route.path; otherwise cross-repo HTTP matching cannot work for prefixed controllers. Tracking this under parsing/cross-repo extraction, with a regression fixture around class-level + method-level mappings as the right first step.

  3. added this to the 0.9.1-rc milestone on Jul 8, 2026
  4. rehanazher commented on Jul 13, 2026

    @rehanazher

    Comment to post on upstream issue #734

    "Java/Spring: class-level @RequestMapping prefix dropped from Route nodes — breaks cross-repo-intelligence for prefixed controllers"
    #734

    NOTE: scrubbed of internal identifiers — generic class/route names only.


    Still reproduces on v0.9.0 (linux-amd64-portable, mode=full) — confirming this isn't fixed by the v0.9.0 extraction work.

    Data point from a production Java/Spring Boot service: of 88 Route nodes, only 3 carry a full path. The rest are bare method-level fragments — e.g. a controller with a class-level @RequestMapping("/api/widgets") and method-level @PostMapping("/") / @PutMapping("/{id}") produces:

    /         POST     WidgetControllerBase.java
    /{id}     PUT      WidgetControllerBase.java
    /{id}     DELETE   WidgetControllerBase.java
    

    The real endpoint is POST /api/widgets, not POST /.

    Downstream effect on the tool surface (beyond the cross-repo edges already described in the issue): find_route_handler cannot match any real endpoint path.

    find_route_handler {"project":"...", "method":"GET", "path":"/api/widgets"}
    → {"results": [], "total": 0}
    

    ...for a route that demonstrably exists.

    Additional root-cause detail: decorator arguments aren't captured at all

    This may be the more general defect worth fixing. Decorator nodes are name-only, deduplicated, with no arguments and no file path:

    MATCH (d:Decorator) WHERE d.name CONTAINS "RequestMapping" RETURN d.name, d.file_path

    → a single row: ["RequestMapping", ""]

    So the base path exists nowhere in the graph — it is not merely un-composed into the Route, it is never captured. That also means a consumer cannot work around the issue by re-composing the path themselves.

    Suggestion

    Two layers:

    1. Capture annotation/decorator arguments on Decorator nodes (with file_path, un-deduplicated). This is generally useful well beyond Spring — it's the same missing data that blocks any annotation-driven framework.
    2. Compose class-level base + method-level path into the Route, either in Route.name or as an additional full_path property (keeping the fragment for backwards compatibility).

    HANDLES edges (Method → Route) already exist and work well — this is the missing piece that would make them actionable.

  5. added
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    and removed
    priority/normalStandard review queue; useful PR with ordinary maintainer urgency.
    on Sep 5, 2026
  6. DeusData commented on Sep 25, 2026

    @DeusData
    Owner

    Thank you, @maehrlae2, for the clean repro, and @rehanazher for the production data point! The main case is fixed as of v0.9.0 (a19fe03): your MccRequirementController example now produces GET /api/corporate/mcc/corporates/{corporateId}/requirements.

    Your …ControllerBase example points at a remaining gap, which we reproduced. When the class-level @RequestMapping sits on the subclass (or on an interface) and the handler methods are inherited from a base class, the prefix isn't applied. We'll track that as a follow-up, and capturing annotation arguments on Decorator nodes as a feature request. Could you confirm the plain-controller case on v0.11.0?

  7. added
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Sep 25, 2026
  8. github-actions commented on Sep 26, 2026

    @github-actions

    Thanks for the report! To move this forward we need a bit more so we can reproduce it ourselves:

    • the codebase-memory-mcp --version you're on
    • the exact steps or command you ran
    • a public repo (or a small dummy snippet) that shows the problem — please don't paste proprietary code

    Once that's here we'll pick it straight back up. Heads-up: issues left awaiting-reporter are automatically closed after a few weeks of silence, but a comment reopens the door anytime.

  9. removed
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Oct 1, 2026
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.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions