weaviate/weaviate · error

apply env config

Error message

apply env config

What it means

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.

Solutions

  1. Inspect the wrapped inner error in the log to see whether the failure came from policy mutation or config validation
  2. Back up and delete the RBAC policy files in the rbac_storage_path so a fresh policy is generated on next start
  3. Fix the admin user/group configuration (AUTHORIZATION_ADMIN_LIST_USERS / _GROUPS), removing namespaced root subjects if namespaces are enabled
  4. Verify the storage volume holding the casbin policy is writable and not full
  5. Restore from a valid policy.csv or re-bootstrap RBAC roles via the API after start

Example fix

// before
AUTHORIZATION_ADMIN_LIST_USERS="admin@weaviate;reader@weaviate"
// after
AUTHORIZATION_ADMIN_LIST_USERS="admin@weaviate"
# plus: mv ./data/rbac/policy.csv ./data/rbac/policy.csv.bak to regenerate a fresh policy
Defensive patterns

Strategy: validation

Validate before calling

// before starting the server with RBAC enabled, preflight the config
const adminUsers = process.env.AUTHORIZATION_ADMIN_LIST_USERS || ''
const adminGroups = process.env.AUTHORIZATION_ADMIN_LIST_GROUPS || ''
if (!adminUsers && !adminGroups) {
  throw new Error('RBAC enabled but no admin users/groups configured')
}
// ensure rbac storage dir is writable
import fs from 'fs'
fs.accessSync(rbacStoragePath, fs.constants.W_OK)

Try / catch

try {
  await startWeaviate()
} catch (err) {
  if (String(err).includes('apply env config')) {
    // inspect wrapped cause, fix admin config or regenerate policy.csv, then retry
  }
  throw err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/fedd09b4e5777a2e. Report an issue: GitHub.

Appendix: source

Thrown at usecases/auth/authorization/rbac/model.go:144

	minorVersion, err := strconv.Atoi(versionParts[1])
	if err != nil {
		return nil, err
	}

	if versionParts[0] == "1" && minorVersion < 30 {
		if err := upgradePoliciesFrom129(enforcer, false); err != nil {
			return nil, err
		}

		if err := upgradeGroupingsFrom129(enforcer, authNconf); err != nil {
			return nil, err
		}
	}
	// docs: https://casbin.org/docs/function/
	enforcer.AddFunction("namespaceAwareMatcher", makeNamespaceAwareMatcherFunc(namespacesEnabled))

	if err := applyPredefinedRoles(enforcer, conf, authNconf, namespacesEnabled); err != nil {
		return nil, errors.Wrapf(err, "apply env config")
	}

	// update version after casbin policy has been written
	if err := writeVersion(rbacStoragePath, build.Version); err != nil {
		return nil, err
	}

	return enforcer, nil
}

// applyPredefinedRoles adds pre-defined roles (admin/viewer/root) and assigns them to the users provided in the
// local config
func applyPredefinedRoles(enforcer *casbin.SyncedCachedEnforcer, conf rbacconf.Config, authNconf config.Authentication, namespacesEnabled bool) error {
	if namespacesEnabled {
		if err := rejectNamespacedRootSubjects(conf); err != nil {
			return err
		}
	}

View on GitHub (pinned to 75aa4b6d11)