{"record":{"id":"95877c5c64962b69","repo":"gofr-dev/gofr","slug":"failed-to-process-unified-config-w","errorCode":null,"errorMessage":"failed to process unified config: %w","messagePattern":"failed to process unified config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/rbac/config.go","lineNumber":173,"sourceCode":"\t}\n\n\t// Set dependencies\n\tconfig.Logger = logger\n\tconfig.Metrics = metrics\n\tconfig.Tracer = tracer\n\n\t// Initialize mux router for pattern matching\n\t// Use StrictSlash(false) to match the application router's behavior\n\tconfig.muxRouter = mux.NewRouter().StrictSlash(false)\n\n\t// Validate config before processing\n\tif err := config.validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid RBAC config: %w\", err)\n\t}\n\n\t// Process unified config to build internal maps\n\tif err := config.processUnifiedConfig(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to process unified config: %w\", err)\n\t}\n\n\treturn &config, nil\n}\n\n// validate validates the RBAC configuration.\nfunc (c *Config) validate() error {\n\t// Validate endpoints: non-public endpoints must have RequiredPermissions\n\t// Also validate that paths use mux patterns only (no wildcards or old regex)\n\tfor i, endpoint := range c.Endpoints {\n\t\tif !endpoint.Public && len(endpoint.RequiredPermissions) == 0 {\n\t\t\treturn fmt.Errorf(\"endpoint[%d]: %w: %s\", i, ErrEndpointMissingPermissions, endpoint.Path)\n\t\t}\n\n\t\t// Validate path pattern\n\t\tif err := c.validateEndpointPath(endpoint.Path, i); err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/rbac/config.go#L155-L191","documentation":"The parsed RBAC config passed validation but processUnifiedConfig failed while converting the unified config into the internal role/permission maps. The internal error is wrapped and typically indicates inconsistent references between roles, permissions, or endpoints.","triggerScenarios":"EnableRBAC/LoadPermissions with a unified config whose roles/permission references are inconsistent (e.g. an endpoint or role referencing a permission that cannot be resolved while building internal maps).","commonSituations":"Renaming a role in one place but not another; typos in permission identifiers; a config merged from multiple sources where cross-references broke.","solutions":["Inspect the wrapped inner error for the specific inconsistent entry.","Verify every role/permission referenced by endpoints is defined in the config.","Diff a previously working config against the current one to spot renamed or removed definitions.","Reduce the config to a minimal working set and add entries back until the failure reappears."],"exampleFix":"// before: endpoint references undefined role\n{ \"path\": \"/api/admin\", \"roles\": [\"superadmin\"] } // 'superadmin' not defined\n// after: define the role first\n{ \"roles\": { \"superadmin\": [\"*\"] }, \"endpoints\": [{ \"path\": \"/api/admin\", \"roles\": [\"superadmin\"] }] }","handlingStrategy":"validation","validationCode":"defined := map[string]bool{}\nfor _, r := range cfg.Roles { defined[r.Name] = true }\nfor i, ep := range cfg.Endpoints {\n    for _, role := range ep.Roles {\n        if !defined[role] {\n            return fmt.Errorf(\"endpoint[%d] %s references undefined role %q\", i, ep.Path, role)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := rbac.LoadPermissions(path, logger, metrics, tracer); err != nil {\n    if strings.Contains(err.Error(), \"failed to process unified config\") {\n        return fmt.Errorf(\"unified config references are inconsistent: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep role and permission definitions in one file to avoid drift.","Cross-check references (roles ↔ permissions, endpoints ↔ roles) in CI.","Grep for renamed identifiers after refactors.","Bisect the config down to a minimal set when the inner error is unclear."],"tags":["go","rbac","config","processing"],"backgroundTag":"schema-validation-failed","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}