{"record":{"id":"fedd09b4e5777a2e","repo":"weaviate/weaviate","slug":"apply-env-config","errorCode":null,"errorMessage":"apply env config","messagePattern":"apply env config","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/auth/authorization/rbac/model.go","lineNumber":144,"sourceCode":"\tminorVersion, err := strconv.Atoi(versionParts[1])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif versionParts[0] == \"1\" && minorVersion < 30 {\n\t\tif err := upgradePoliciesFrom129(enforcer, false); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif err := upgradeGroupingsFrom129(enforcer, authNconf); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\t// docs: https://casbin.org/docs/function/\n\tenforcer.AddFunction(\"namespaceAwareMatcher\", makeNamespaceAwareMatcherFunc(namespacesEnabled))\n\n\tif err := applyPredefinedRoles(enforcer, conf, authNconf, namespacesEnabled); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"apply env config\")\n\t}\n\n\t// update version after casbin policy has been written\n\tif err := writeVersion(rbacStoragePath, build.Version); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn enforcer, nil\n}\n\n// applyPredefinedRoles adds pre-defined roles (admin/viewer/root) and assigns them to the users provided in the\n// local config\nfunc applyPredefinedRoles(enforcer *casbin.SyncedCachedEnforcer, conf rbacconf.Config, authNconf config.Authentication, namespacesEnabled bool) error {\n\tif namespacesEnabled {\n\t\tif err := rejectNamespacedRootSubjects(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/auth/authorization/rbac/model.go#L126-L162","documentation":"Weaviate wraps any failure that occurs while applying predefined RBAC roles to the Casbin enforcer during RBAC initialization (usecases/auth/authorization/rbac/model.go:144). Init builds/loads the casbin policy from disk, then calls applyPredefinedRoles which wipes and re-registers the built-in admin/viewer/root roles and maps them to the users/groups configured via environment or config. Any error returned by that function (or the enforcer's Casbin storage layer) is wrapped with \"apply env config\" and aborts server startup.","triggerScenarios":"Server startup (Init, called from New) with RBAC enabled when: the on-disk casbin policy CSV is corrupt or unreadable, the enforcer cannot persist AddRoleForUser/AddPolicy/RemoveFilteredNamedPolicy operations, namespaced root subjects are misconfigured (rejectNamespacedRootSubjects fails), or group/user assignments in config (AUTHORIZATION_ADMIN_* env vars) reference invalid values.","commonSituations":"Upgrading Weaviate with a stale or partially-written policy.csv in the RBAC storage path; a container restart with a read-only or full disk holding the RBAC state; invalid AUTHORIZATION_ADMIN_LIST env entries; switching multi-tenancy namespacesEnabled flags between versions.","solutions":["Inspect the wrapped inner error in the log to see whether the failure came from policy mutation or config validation","Back up and delete the RBAC policy files in the rbac_storage_path so a fresh policy is generated on next start","Fix the admin user/group configuration (AUTHORIZATION_ADMIN_LIST_USERS / _GROUPS), removing namespaced root subjects if namespaces are enabled","Verify the storage volume holding the casbin policy is writable and not full","Restore from a valid policy.csv or re-bootstrap RBAC roles via the API after start"],"exampleFix":"// before\nAUTHORIZATION_ADMIN_LIST_USERS=\"admin@weaviate;reader@weaviate\"\n// after\nAUTHORIZATION_ADMIN_LIST_USERS=\"admin@weaviate\"\n# plus: mv ./data/rbac/policy.csv ./data/rbac/policy.csv.bak to regenerate a fresh policy","handlingStrategy":"validation","validationCode":"// before starting the server with RBAC enabled, preflight the config\nconst adminUsers = process.env.AUTHORIZATION_ADMIN_LIST_USERS || ''\nconst adminGroups = process.env.AUTHORIZATION_ADMIN_LIST_GROUPS || ''\nif (!adminUsers && !adminGroups) {\n  throw new Error('RBAC enabled but no admin users/groups configured')\n}\n// ensure rbac storage dir is writable\nimport fs from 'fs'\nfs.accessSync(rbacStoragePath, fs.constants.W_OK)","typeGuard":null,"tryCatchPattern":"try {\n  await startWeaviate()\n} catch (err) {\n  if (String(err).includes('apply env config')) {\n    // inspect wrapped cause, fix admin config or regenerate policy.csv, then retry\n  }\n  throw err\n}","preventionTips":["Validate AUTHORIZATION_ADMIN_LIST_* values in CI before deployment","Mount the RBAC storage path on a writable persistent volume","Back up policy.csv before upgrading Weaviate versions","Avoid mixing namespaced root subjects when namespaces are enabled"],"tags":["rbac","casbin","startup","authorization"],"backgroundTag":"rbac-policy-init-failure","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}