{"record":{"id":"8ff63cd2ea9c8699","repo":"gofr-dev/gofr","slug":"unsupported-config-file-format","errorCode":null,"errorMessage":"unsupported config file format","messagePattern":"unsupported config file format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/rbac/config.go","lineNumber":22,"sourceCode":"\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\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)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/rbac/config.go#L4-L40","documentation":"errUnsupportedFormat is returned by rbac.LoadPermissions when the RBAC permissions config file has an extension other than the supported .json, .yaml, or .yml. LoadPermissions detects the format via the file extension (strings.ToLower(filepath.Ext(path))) and refuses to parse anything else. This prevents silently mis-parsing config files with an unrecognized structure.","triggerScenarios":"Calling LoadPermissions(path, ...) or EnableRBAC with a file whose extension is e.g. .toml, .ini, .xml, .txt, or no extension.","commonSituations":"Teams exporting permissions from another tool as TOML/INI; config file renamed or copied without its extension; YAML file saved as .config; typo like permissons.ymlx.","solutions":["Convert the config file to JSON, YAML (.yaml), or YML (.yml).","Rename the file to have the correct extension matching its actual content.","If the file already IS JSON/YAML but misnamed, fix the extension — format detection is extension-based only."],"exampleFix":"// before\nroles, err := rbac.LoadPermissions(\"rbac.toml\", logger, metrics, tracer)\n// after\nroles, err := rbac.LoadPermissions(\"rbac.yaml\", logger, metrics, tracer)","handlingStrategy":"validation","validationCode":"func validateRBACPath(path string) error {\n\text := strings.ToLower(filepath.Ext(path))\n\tswitch ext {\n\tcase \".json\", \".yaml\", \".yml\":\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported rbac config extension %q; use .json/.yaml/.yml\", ext)\n\t}\n}","typeGuard":null,"tryCatchPattern":"cfg, err := rbac.LoadPermissions(path, logger, metrics, tracer)\nif err != nil {\n\treturn fmt.Errorf(\"rbac config load failed: %w\", err)\n}","preventionTips":["Standardize on a single format (e.g. .yaml) across services.","Add a CI check that all RBAC config files end in .json/.yaml/.yml.","Never rename config files manually — re-export in a supported format.","Document the format requirement next to where the path is configured."],"tags":["rbac","config","validation","gofr"],"backgroundTag":"unsupported-config-format","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}