{"record":{"id":"d9ebb99c2ba91776","repo":"chenhg5/cc-connect","slug":"config-s-users-default-role-q-does-not-match-an","errorCode":null,"errorMessage":"config: %s.users.default_role %q does not match any defined role","messagePattern":"config: (.+?)\\.users\\.default_role %q does not match any defined role","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":1192,"sourceCode":"\t\t}\n\t\tfor _, uid := range rc.UserIDs {\n\t\t\tif uid == \"*\" {\n\t\t\t\twildcardCount++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlower := strings.ToLower(uid)\n\t\t\tif prev, dup := seenUserIDs[lower]; dup {\n\t\t\t\treturn fmt.Errorf(\"config: %s.users: user %q appears in both role %q and %q\", prefix, uid, prev, roleName)\n\t\t\t}\n\t\t\tseenUserIDs[lower] = roleName\n\t\t}\n\t}\n\tif wildcardCount > 1 {\n\t\treturn fmt.Errorf(\"config: %s.users: wildcard user_ids=[\\\"*\\\"] appears in multiple roles\", prefix)\n\t}\n\tif u.DefaultRole != \"\" {\n\t\tif _, ok := u.Roles[u.DefaultRole]; !ok {\n\t\t\treturn fmt.Errorf(\"config: %s.users.default_role %q does not match any defined role\", prefix, u.DefaultRole)\n\t\t}\n\t}\n\treturn nil\n}\n\n// SaveActiveProvider persists the active provider name for a project.\n// It uses surgical text editing to preserve comments and unknown fields.\nfunc SaveActiveProvider(projectName, providerName string) error {\n\tconfigMu.Lock()\n\tdefer configMu.Unlock()\n\treturn patchProjectAgentOption(projectName, \"provider\", providerName)\n}\n\n// SaveProviderModel persists the selected model for a provider in a project.\n// It first looks in the project's inline providers, then falls back to\n// global [[providers]] if the provider is referenced via provider_refs.\n// Uses surgical text editing to preserve comments and unknown fields.\nfunc SaveProviderModel(projectName, providerName, model string) error {","sourceCodeStart":1174,"sourceCodeEnd":1210,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L1174-L1210","documentation":"This error means the project's users.default_role names a role that is not defined in that same users block. The default role is what unlisted users fall back to, so it must reference an existing role key; otherwise fallback would be undefined.","triggerScenarios":"Config load/validation when u.DefaultRole is non-empty and u.Roles[u.DefaultRole] does not exist — e.g. default_role = \"member\" but only roles \"user\" and \"admin\" are defined, or a typo/renamed role.","commonSituations":"Renaming a role in config but forgetting to update default_role; adding default_role before ever defining the roles table; copy-pasting a users block between projects and trimming roles.","solutions":["Set default_role to an exact role key that exists in the same users block","Or define the missing role under the roles table","Check for typos/case differences between default_role and the role names"],"exampleFix":"// before\ndefault_role = \"member\"\nroles.user.user_ids = [\"*\"]\n// after\ndefault_role = \"user\"\nroles.user.user_ids = [\"*\"]","handlingStrategy":"validation","validationCode":"if u.DefaultRole != \"\" {\n\tif _, ok := u.Roles[u.DefaultRole]; !ok {\n\t\treturn fmt.Errorf(\"default_role %q undefined\", u.DefaultRole)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := loadConfig(path); err != nil {\n\tif strings.Contains(err.Error(), \"default_role\") {\n\t\t// align default_role with a defined role key\n\t}\n\treturn err\n}","preventionTips":["Rename roles and default_role in the same edit","Generate default_role from the roles map keys in tooling","Keep role names lowercase snake to avoid case mismatches"],"tags":["config","validation","default-role"],"backgroundTag":"invalid-config-value","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}