{"record":{"id":"f76f86d6916856db","repo":"gofr-dev/gofr","slug":"wildcard-pattern-is-not-supported-use-mux-pa","errorCode":null,"errorMessage":"wildcard pattern '/*' is not supported, use mux patterns instead","messagePattern":"wildcard pattern '/\\*' is not supported, use mux patterns instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/rbac/config.go","lineNumber":28,"sourceCode":"\t\"strings\"\n\n\t\"github.com/gorilla/mux\"\n\t\"go.opentelemetry.io/otel/trace\"\n\t\"gopkg.in/yaml.v3\"\n\n\t\"gofr.dev/pkg/gofr/container\"\n\t\"gofr.dev/pkg/gofr/datasource\"\n)\n\nvar (\n\t// errUnsupportedFormat is returned when the config file format is not supported.\n\terrUnsupportedFormat = errors.New(\"unsupported config file format\")\n\n\t// ErrEndpointMissingPermissions is returned when an endpoint doesn't specify requiredPermissions and is not public.\n\tErrEndpointMissingPermissions = errors.New(\"endpoint must specify requiredPermissions (or be public)\")\n\n\t// errWildcardPatternNotSupported is returned when a wildcard pattern is used.\n\terrWildcardPatternNotSupported = errors.New(\"wildcard pattern '/*' is not supported, use mux patterns instead\")\n\n\t// errRegexPatternNotSupported is returned when an old regex pattern is used.\n\terrRegexPatternNotSupported = errors.New(\"regex pattern '^...$' is not supported, use mux patterns instead\")\n\n\t// errRegexIndicatorNotSupported is returned when regex indicators are used outside variable constraints.\n\terrRegexIndicatorNotSupported = errors.New(\"regex pattern is not supported, use mux patterns instead\")\n)\n\n// RoleDefinition defines a role with its permissions and inheritance.\n// Pure config-based: only role->permission mapping is supported.\ntype RoleDefinition struct {\n\t// Name is the role name (required)\n\tName string `json:\"name\" yaml:\"name\"`\n\n\t// Permissions is a list of permissions for this role (format: \"resource:action\")\n\t// Example: [\"users:read\", \"users:write\"]\n\tPermissions []string `json:\"permissions,omitempty\" yaml:\"permissions,omitempty\"`\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/rbac/config.go#L10-L46","documentation":"errWildcardPatternNotSupported is returned by checkWildcardPattern when a route path in the RBAC config contains a trailing '/*' wildcard. GoFr RBAC requires mux-style patterns (e.g. named path variables) instead of wildcard suffixes, so '/*' patterns are rejected during validation to keep matching semantics unambiguous.","triggerScenarios":"Declaring an endpoint path in the RBAC permissions config like '/api/v1/*' or '/files/*'; LoadPermissions/validate calls checkWildcardPattern on each pattern and returns this error.","commonSituations":"Porting an RBAC config from another framework (Express/Chi style wildcards); writing catch-all routes for static assets or versioned APIs; copying legacy gateway route rules.","solutions":["Replace the '/*' wildcard with a mux pattern, e.g. '/{path...}' style variable or enumerate concrete paths.","Use mux route variables like '/api/v1/{resource}' instead of '/api/v1/*'.","List explicit child routes in the config if catch-all behavior is not truly needed.","Keep legacy wildcard patterns out of RBAC config; apply them at the router level instead."],"exampleFix":"// before\n\"/api/v1/*\": {\"GET\": [\"user\"]}\n// after\n\"/api/v1/{resource}\": {\"GET\": [\"user\"]}","handlingStrategy":"validation","validationCode":"func hasWildcardSuffix(pattern string) bool {\n\treturn strings.HasSuffix(pattern, \"/*\")\n}\n// fail before LoadPermissions if any pattern matches","typeGuard":null,"tryCatchPattern":"if err := checkWildcardPattern(pattern); err != nil {\n\treturn fmt.Errorf(\"invalid RBAC pattern %q: %w\", pattern, err)\n}","preventionTips":["Use mux variables like {param} instead of trailing wildcards.","Enumerate concrete child routes instead of catch-alls where possible.","Add a pre-commit check scanning RBAC configs for '/*' suffixes.","Keep a migration note when porting configs from wildcard-based routers."],"tags":["rbac","config","routing","gofr"],"backgroundTag":"unsupported-route-pattern","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}