{"record":{"id":"84a21a7475722620","repo":"gofr-dev/gofr","slug":"endpoint-d-w-s-example-api-users-id-0-9-84a21a","errorCode":null,"errorMessage":"endpoint[%d]: %w: %s. Example: /api/users/{id:[0-9]+}","messagePattern":"endpoint\\[(.+?)\\]: %w: (.+?)\\. Example: /api/users/(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/rbac/config.go","lineNumber":254,"sourceCode":"\treturn nil\n}\n\n// checkRegexPattern checks if path contains old regex pattern.\nfunc (*Config) checkRegexPattern(path string, index int) error {\n\tif strings.HasPrefix(path, \"^\") || strings.HasSuffix(path, \"$\") {\n\t\treturn fmt.Errorf(\"endpoint[%d]: %w: %s. Example: /api/users/{id:[0-9]+} instead of ^/api/users/\\\\d+$\",\n\t\t\tindex, errRegexPatternNotSupported, path)\n\t}\n\n\treturn nil\n}\n\n// checkRegexIndicators checks if path contains regex indicators outside variable constraints.\nfunc (*Config) checkRegexIndicators(path string, index int) error {\n\tif strings.Contains(path, \"\\\\d\") || strings.Contains(path, \"\\\\w\") || strings.Contains(path, \"\\\\s\") {\n\t\t// Only allow if it's inside a variable constraint like {id:[0-9]+}\n\t\tif !strings.Contains(path, \"{\") || !strings.Contains(path, \":\") {\n\t\t\treturn fmt.Errorf(\"endpoint[%d]: %w: %s. Example: /api/users/{id:[0-9]+}\",\n\t\t\t\tindex, errRegexIndicatorNotSupported, path)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// processUnifiedConfig processes the unified Roles and Endpoints config\n// and builds internal maps for efficient lookup.\n// Config is read-only after initialization, so no mutex is needed.\nfunc (c *Config) processUnifiedConfig() error {\n\tc.initializeMaps()\n\tc.buildRolePermissionsMap()\n\n\treturn c.buildEndpointPermissionMap()\n}\n\n// initializeMaps initializes internal maps.","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/rbac/config.go#L236-L272","documentation":"checkRegexIndicators found regex escapes (\\\\d, \\\\w, \\\\s) in the path outside any mux variable constraint. Bare regex escapes in paths are unsupported; move them inside a {var:constraint} expression or remove them.","triggerScenarios":"An endpoint path like /api/users/\\\\d+ (no braces/colon present) passed to EnableRBAC/LoadPermissions via validate -> validateEndpointPath -> checkRegexIndicators.","commonSituations":"Partial migration from regex routes where anchors were removed but escapes remained; hand-written numeric-segment paths; copy-paste from regex route tables.","solutions":["Wrap the regex segment in a named variable with constraint: /api/users/{id:[0-9]+}.","Or remove the escape and use a plain segment or {resource} if no regex is needed.","Search the config for \\\\d, \\\\w, \\\\s and fix each occurrence."],"exampleFix":"// before\npath: \"/api/users/\\\\d+\"\n// after\npath: \"/api/users/{id:[0-9]+}\"","handlingStrategy":"validation","validationCode":"func bareRegexEscape(p string) bool {\n    for _, esc := range []string{\"\\\\d\", \"\\\\w\", \"\\\\s\"} {\n        if strings.Contains(p, esc) && !(strings.Contains(p, \"{\") && strings.Contains(p, \":\")) {\n            return true\n        }\n    }\n    return false\n}\nfor i, ep := range endpoints {\n    if bareRegexEscape(ep.Path) {\n        return fmt.Errorf(\"endpoint[%d] %s: move regex escapes into a constraint like {id:[0-9]+}\", i, ep.Path)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := prevalidateRegexIndicators(endpoints); err != nil { return err }\nif _, err := rbac.LoadPermissions(path, logger, metrics, tracer); err != nil {\n    if strings.Contains(err.Error(), \"Example: /api/users/{id:[0-9]+}\") {\n        return fmt.Errorf(\"wrap regex escapes in variable constraints: %w\", err)\n    }\n    return err\n}","preventionTips":["Lint for \\\\d, \\\\w, \\\\s outside braces in path configs.","Prefer named mux constraints ({id:[0-9]+}) over bare escapes.","Keep a migration checklist when converting regex route tables.","Add tests asserting each configured path matches its intended URLs."],"tags":["go","rbac","routing","regex","validation"],"backgroundTag":"invalid-route-pattern","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}