#3402·GitNexus

Go gin/echo routes are never indexed: route_map is empty and impact stops at the handler (false-safe LOW)

Author: rgb-vgxCreated Sep 28, 2026Updated Sep 28, 2026

Area

gitnexus (CLI / core / indexing / MCP server)

Summary

Go HTTP routes (gin / echo) are never turned into Route nodes during analyze, so route_map returns nothing for a Go backend and upstream impact from a service method stops at the HTTP handler with risk: LOW, even when the handler is registered on a route and called by a frontend.

Context

gitnexus/src/core/ingestion/route-extractors/ has extractors for Spring, Kotlin Spring, Laravel, Next.js, Expo, NestJS, Django, FastAPI, tRPC, JS/TS dispatch guards and data route tables. There is no Go extractor, and the Go LanguageProvider does not implement extractDecoratorRoutes. Go routes are only read in group mode, through the source-scan plugin core/group/extractors/http-patterns/go.ts.

That plugin had two gaps of its own: method-value handlers (admin.POST("/x", h.Method)) were dropped, and Group("/p") prefixes were ignored. Both are fixed in a separate PR (link to follow). This issue covers the index side, which that PR does not touch.

Expected behavior

For a gin router such as

go
func RegisterRoutes(r *gin.Engine, svc *service.Service) {
	matchHandler := NewMatchHandler(svc.Match)
	v1 := r.Group("/api/v1")
	{
		admin := v1.Group("/admin")
		admin.POST("/seasons/:seasonId/rounds/:roundId/unfinalize", matchHandler.UnfinalizeRoundHandle)
	}
}
  • analyze creates Route {name: "/api/v1/admin/seasons/:seasonId/rounds/:roundId/unfinalize", method: "POST"}, with a HANDLES_ROUTE edge from MatchHandler.UnfinalizeRoundHandle (defined in match_handler.go, not the router file);
  • route_map lists the route with its handler and any FETCHES consumers;
  • upstream impact from a service method the handler calls reaches the route.

Actual behavior

Measured on a real gin + React/Vite project with 254 gin routes, all under r.Group("/api/v1"), with 245 of them using method-value handlers. Indexed on current main:

  • MATCH (r:Route) RETURN count(r) → 0
  • impact UnfinalizeRound --direction upstream → risk: LOW, 1–2 direct callers, ending at UnfinalizeRoundHandle. The route and the two frontend call sites are invisible, so an agent that trusts LOW edits without them.

Steps to reproduce

  1. Create a Go module with the RegisterRoutes above, plus match_handler.go declaring type MatchHandler struct{…} and func (h *MatchHandler) UnfinalizeRoundHandle(c *gin.Context).
  2. gitnexus analyze
  3. gitnexus cypher "MATCH (r:Route) RETURN count(r)" → 0; route_map is empty.

Proposed direction

I'd like to work on this, and I'd appreciate a steer on handler resolution before opening the PR.

  1. Extraction. Add route-extractors/go-gin.ts and wire it as the Go provider's extractDecoratorRoutes, with source set so the HANDLES_ROUTE edge does not claim a decorator. It would share the in-function Group(...) prefix walk with the group-mode plugin, so both layers produce the same paths.

  2. Handler resolution. This is the open question. The routes phase resolves handlerName by (filePath, name) in the route's own file, but gin handlers are almost always methods defined in another file of the same package (matchHandler.UnfinalizeRoundHandle). The receiver is a local variable, not a type. Options, most precise first:

    • (a) Infer the receiver's type in the router function from h := &T{…} / T{…}, or from h := NewT(…) via the constructor's declared result type. Then resolve T.Method with model.methods.lookupAllByOwner, as data route tables already do for Owner.member.
    • (b) Fall back to a unique Method with that name among the files of the router's package, i.e. the same directory, since a Go package is a directory. This declines on ambiguity (e.g. AuthHandler.Login and AdminAuthHandler.Login).
    • (c) For pkg.Func, resolve the Go import to its package directory and look up a unique function there.

    Anything unresolved is emitted without handlerSymbolId, following the existing fail-open contract. My plan is (a) + (b) + (c). Would you prefer something narrower, e.g. only (a), or reusing the Go scope resolver's type bindings instead of a local inference?

  3. Out of scope for the first PR: groups passed to another function (registerAdmin(v1)), chi (r.Get / r.Route), and echo's trailing route-level middleware.

Acceptance criteria

  • A test/integration/go-gin-route-pipeline.test.ts (modelled on nest-route-pipeline.test.ts) asserting Route nodes with full group prefixes, method and handlerSymbolId for selector, identifier, package-function and inline handlers; ambiguous handlers get no handlerSymbolId.
  • route_map returns those routes; impact upstream from a handler dependency reaches the route.
  • No change for other languages; shared ingestion code does not name Go (via LanguageProvider).

Source: abhigyanpatwari/GitNexus