{"record":{"id":"82bfaa05f6d10d3a","repo":"gofr-dev/gofr","slug":"unsupported-config-file-format-s-supported-js","errorCode":null,"errorMessage":"unsupported config file format: %s (supported: .json, .yaml, .yml): %w","messagePattern":"unsupported config file format: (.+?) \\(supported: \\.json, \\.yaml, \\.yml\\): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/rbac/config.go","lineNumber":154,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read RBAC config file %s: %w\", path, err)\n\t}\n\n\tvar config Config\n\n\t// Detect file format by extension\n\text := strings.ToLower(filepath.Ext(path))\n\tswitch ext {\n\tcase \".yaml\", \".yml\":\n\t\tif err := yaml.Unmarshal(data, &config); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse YAML config file %s: %w\", path, err)\n\t\t}\n\tcase \".json\", \"\":\n\t\tif err := json.Unmarshal(data, &config); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse JSON config file %s: %w\", path, err)\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported config file format: %s (supported: .json, .yaml, .yml): %w\", ext, errUnsupportedFormat)\n\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 {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/rbac/config.go#L136-L172","documentation":"LoadPermissions only supports .json, .yaml, and .yml config files (extension-less files are treated as JSON). Any other extension — .toml, .conf, .txt, .xml — is rejected with errUnsupportedFormat and the RBAC config is not loaded.","triggerScenarios":"Passing EnableRBAC/LoadPermissions a path ending in an extension outside {.json, .yaml, .yml}, e.g. /etc/app/rbac.toml or rbac.config.","commonSituations":"Reusing an existing TOML/INI config; a deployment renamed the file to .bak or added a timestamp suffix; writing config as .yml.txt due to editor auto-extension.","solutions":["Rename the config file to one of the supported extensions (.json, .yaml, .yml).","Convert unsupported formats (TOML/INI/XML) to JSON or YAML.","If the file is intentionally extension-less, ensure its content is valid JSON since \"\" falls into the JSON branch."],"exampleFix":"// before\nconfig, err := rbac.LoadPermissions(\"configs/rbac.toml\", ...)\n// after\nconfig, err := rbac.LoadPermissions(\"configs/rbac.yaml\", ...)","handlingStrategy":"validation","validationCode":"ext := strings.ToLower(filepath.Ext(path))\nswitch ext {\ncase \".json\", \"\", \".yaml\", \".yml\":\n    // ok\ndefault:\n    return fmt.Errorf(\"config %s has unsupported extension %q; use .json/.yaml/.yml\", path, ext)\n}","typeGuard":null,"tryCatchPattern":"config, err := rbac.LoadPermissions(path, logger, metrics, tracer)\nif err != nil && strings.Contains(err.Error(), \"unsupported config file format\") {\n    logger.Fatalf(\"rename %s to .json/.yaml/.yml\", path)\n}","preventionTips":["Standardize on a single supported extension (e.g. .yaml) in your repo.","Check the extension in a startup preflight before calling EnableRBAC.","Watch for deploy-time renames (.bak, timestamped suffixes)."],"tags":["go","config","rbac","file-format","unsupported"],"backgroundTag":"unsupported-file-format","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}