{"id":"fa49e64c55dc56dc","repo":"gorilla/mux","slug":"mux-route-doesn-t-have-queries","errorCode":null,"errorMessage":"mux: route doesn't have queries","messagePattern":"mux: route doesn't have queries","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"route.go","lineNumber":735,"sourceCode":"\t\treturn \"\", r.err\n\t}\n\tif r.regexp.path == nil {\n\t\treturn \"\", errors.New(\"mux: route does not have a path\")\n\t}\n\treturn r.regexp.path.regexp.String(), nil\n}\n\n// GetQueriesRegexp returns the expanded regular expressions used to match the\n// route queries.\n// This is useful for building simple REST API documentation and for instrumentation\n// against third-party services.\n// An error will be returned if the route does not have queries.\nfunc (r *Route) GetQueriesRegexp() ([]string, error) {\n\tif r.err != nil {\n\t\treturn nil, r.err\n\t}\n\tif r.regexp.queries == nil {\n\t\treturn nil, errors.New(\"mux: route doesn't have queries\")\n\t}\n\tqueries := make([]string, 0, len(r.regexp.queries))\n\tfor _, query := range r.regexp.queries {\n\t\tqueries = append(queries, query.regexp.String())\n\t}\n\treturn queries, nil\n}\n\n// GetQueriesTemplates returns the templates used to build the\n// query matching.\n// This is useful for building simple REST API documentation and for instrumentation\n// against third-party services.\n// An error will be returned if the route does not define queries.\nfunc (r *Route) GetQueriesTemplates() ([]string, error) {\n\tif r.err != nil {\n\t\treturn nil, r.err\n\t}\n\tif r.regexp.queries == nil {","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/gorilla/mux/blob/db9d1d0073d27a0a2d9a8c1bc52aa0af4374d265/route.go#L717-L753","documentation":"Returned by Route.GetQueriesRegexp (route.go:730-735) when the route has no query matchers (r.regexp.queries == nil). Intended for documentation/instrumentation; returns the compiled regexps of registered .Queries(...) matchers.","triggerScenarios":"Calling GetQueriesRegexp() on a route that never had .Queries(...) called.","commonSituations":"Docs/metrics iterating all routes; routes that match path but not query.","solutions":["Treat the error as 'no queries' and skip/nil it.","Use GetQueriesTemplates for the raw templates.","Filter to query-bearing routes."],"exampleFix":"// before\nqs, err := route.GetQueriesRegexp()\n\n// after\nqs, err := route.GetQueriesRegexp()\nif err != nil { qs = nil }","handlingStrategy":"try-catch","validationCode":"qs, err := route.GetQueriesRegexp()\nif err != nil { qs = nil }","typeGuard":"func hasQueries(rt *mux.Route) bool { _, err := rt.GetQueriesRegexp(); return err == nil }","tryCatchPattern":"qs, err := rt.GetQueriesRegexp()\nif err != nil { qs = nil }","preventionTips":["Treat the error as 'no queries'.","Defensive introspection.","Document query-bearing routes."],"tags":["routing","introspection","query","docs"],"analyzedSha":"db9d1d0073d27a0a2d9a8c1bc52aa0af4374d265","analyzedAt":"2026-08-04T21:35:47.097Z","schemaVersion":2}