Go gin/echo routes are never indexed: route_map is empty and impact stops at the handler (false-safe LOW)
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
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)
}
}analyzecreatesRoute {name: "/api/v1/admin/seasons/:seasonId/rounds/:roundId/unfinalize", method: "POST"}, with aHANDLES_ROUTEedge fromMatchHandler.UnfinalizeRoundHandle(defined inmatch_handler.go, not the router file);route_maplists the route with its handler and anyFETCHESconsumers;- upstream
impactfrom 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)→0impact UnfinalizeRound --direction upstream→risk: LOW, 1–2 direct callers, ending atUnfinalizeRoundHandle. The route and the two frontend call sites are invisible, so an agent that trustsLOWedits without them.
Steps to reproduce
- Create a Go module with the
RegisterRoutesabove, plusmatch_handler.godeclaringtype MatchHandler struct{…}andfunc (h *MatchHandler) UnfinalizeRoundHandle(c *gin.Context). gitnexus analyzegitnexus cypher "MATCH (r:Route) RETURN count(r)"→ 0;route_mapis empty.
Proposed direction
I'd like to work on this, and I'd appreciate a steer on handler resolution before opening the PR.
Extraction. Add
route-extractors/go-gin.tsand wire it as the Go provider'sextractDecoratorRoutes, withsourceset so theHANDLES_ROUTEedge does not claim a decorator. It would share the in-functionGroup(...)prefix walk with the group-mode plugin, so both layers produce the same paths.Handler resolution. This is the open question. The routes phase resolves
handlerNameby(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 fromh := NewT(…)via the constructor's declared result type. Then resolveT.Methodwithmodel.methods.lookupAllByOwner, as data route tables already do forOwner.member. - (b) Fall back to a unique
Methodwith 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.LoginandAdminAuthHandler.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?- (a) Infer the receiver's type in the router function from
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 onnest-route-pipeline.test.ts) asserting Route nodes with full group prefixes, method andhandlerSymbolIdfor selector, identifier, package-function and inline handlers; ambiguous handlers get nohandlerSymbolId. route_mapreturns those routes;impactupstream from a handler dependency reaches the route.- No change for other languages; shared ingestion code does not name Go (via
LanguageProvider).
Source: abhigyanpatwari/GitNexus