gofr-dev/gofr · error
endpoint[%d]: %w: %s. Examples: /api/{resource} for single-l
Error message
endpoint[%d]: %w: %s. Examples: /api/{resource} for single-level or /api/{path:.*} for multi-level What it means
checkWildcardPattern rejected a path containing "/*". The RBAC config no longer supports wildcard suffixes; use mux variable patterns instead: {resource} for a single segment or {path:.*} for multiple segments.
Source
Thrown at pkg/gofr/rbac/config.go:232
// Reject regex indicators outside of variable constraints
if err := c.checkRegexIndicators(path, index); err != nil {
return err
}
// Validate mux pattern syntax if it contains variables
if isMuxPattern(path) {
if err := validateMuxPattern(path); err != nil {
return fmt.Errorf("endpoint[%d]: invalid mux pattern: %w", index, err)
}
}
return nil
}
// checkWildcardPattern checks if path contains wildcard pattern.
func (*Config) checkWildcardPattern(path string, index int) error {
if strings.Contains(path, "/*") {
return fmt.Errorf("endpoint[%d]: %w: %s. Examples: /api/{resource} for single-level or /api/{path:.*} for multi-level",
index, errWildcardPatternNotSupported, path)
}
return nil
}
// checkRegexPattern checks if path contains old regex pattern.
func (*Config) checkRegexPattern(path string, index int) error {
if strings.HasPrefix(path, "^") || strings.HasSuffix(path, "$") {
return fmt.Errorf("endpoint[%d]: %w: %s. Example: /api/users/{id:[0-9]+} instead of ^/api/users/\\d+$",
index, errRegexPatternNotSupported, path)
}
return nil
}
// checkRegexIndicators checks if path contains regex indicators outside variable constraints.
func (*Config) checkRegexIndicators(path string, index int) error {View on GitHub (pinned to 187eb24962)
Solutions
- Replace /api/* with /api/{path:.*} for multi-level matching.
- Use /api/{resource} when only a single segment is needed.
- Enumerate explicit paths if you prefer no variable patterns.
- Search your config for "/*" occurrences and convert each one.
Example fix
// before
path: "/api/users/*"
// after
path: "/api/users/{path:.*}" Defensive patterns
Strategy: validation
Validate before calling
for i, ep := range endpoints {
if strings.Contains(ep.Path, "/*") {
return fmt.Errorf("endpoint[%d] %s: replace '/*' with mux variable {path:.*} (single level: {resource})", i, ep.Path)
}
} Try / catch
if err := prevalidateWildcard(endpoints); err != nil { return err }
if _, err := rbac.LoadPermissions(path, logger, metrics, tracer); err != nil {
if strings.Contains(err.Error(), "Examples: /api/{resource}") {
return fmt.Errorf("rewrite wildcard paths: %w", err)
}
return err
} Prevention
- Search configs for "/*" in CI and fail the build when found.
- Document the mux replacement ({path:.*}) for team migrations.
- When copying routes from other frameworks, always translate wildcard globs.
When it happens
Trigger: An endpoint path like /api/users/* or /admin/* passed to EnableRBAC/LoadPermissions via validate -> validateEndpointPath -> checkWildcardPattern.
Common situations: Migrating from an older router/config format that used trailing /* globs; copying wildcard routes from Express-style frameworks; broadening an existing route to cover sub-paths.
Related errors
- endpoint[%d]: invalid mux pattern: %w
- endpoint[%d]: %w: %s. Example: /api/users/{id:[0-9]+} instea
- endpoint[%d]: %w: %s. Example: /api/users/{id:[0-9]+}
- invalid RBAC config: %w
- endpoint[%d]: %w: %s
AI-assisted analysis of gofr-dev/gofr@187eb24962 (2026-09-01).
Data as JSON: /api/errors/37be229ac4ee1894.
Report an issue: GitHub.