{"record":{"id":"09d0f4dab9fa83df","repo":"chenhg5/cc-connect","slug":"config-s-users-has-no-roles-defined","errorCode":null,"errorMessage":"config: %s.users has no roles defined","messagePattern":"config: (.+?)\\.users has no roles defined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":1167,"sourceCode":"\tif _, ok := supportedReferenceDisplayPaths[strings.ToLower(strings.TrimSpace(rc.DisplayPath))]; !ok {\n\t\treturn fmt.Errorf(\"config: %s.references.display_path has unsupported value %q\", prefix, rc.DisplayPath)\n\t}\n\tif _, ok := supportedReferenceMarkerStyles[strings.ToLower(strings.TrimSpace(rc.MarkerStyle))]; !ok {\n\t\treturn fmt.Errorf(\"config: %s.references.marker_style has unsupported value %q\", prefix, rc.MarkerStyle)\n\t}\n\tif _, ok := supportedReferenceEnclosureStyles[strings.ToLower(strings.TrimSpace(rc.EnclosureStyle))]; !ok {\n\t\treturn fmt.Errorf(\"config: %s.references.enclosure_style has unsupported value %q\", prefix, rc.EnclosureStyle)\n\t}\n\treturn nil\n}\n\n// validateUsersConfig checks the [projects.users] section for consistency.\nfunc validateUsersConfig(prefix string, u *UsersConfig) error {\n\tif u == nil {\n\t\treturn nil\n\t}\n\tif len(u.Roles) == 0 {\n\t\treturn fmt.Errorf(\"config: %s.users has no roles defined\", prefix)\n\t}\n\twildcardCount := 0\n\tseenUserIDs := make(map[string]string) // userID → role name\n\tfor roleName, rc := range u.Roles {\n\t\tif len(rc.UserIDs) == 0 {\n\t\t\treturn fmt.Errorf(\"config: %s.users.roles.%s has empty user_ids\", prefix, roleName)\n\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}","sourceCodeStart":1149,"sourceCodeEnd":1185,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L1149-L1185","documentation":"CC-Connect requires that a project with a `[projects.users]` section defines at least one role. If `UsersConfig.Roles` is empty (the section exists but no `roles` tables are declared), validateUsersConfig rejects the config. This prevents silently deploying a project where no authorization rules apply.","triggerScenarios":"Loading config.toml containing an empty `[projects.<name>.users]` table with no `[[projects.<name>.users.roles]]` entries, e.g. just `[projects.myapp.users]` with nothing under it.","commonSituations":"Creating the users section as a placeholder before adding roles; commenting out all role blocks while keeping the parent header; a merge/upgrade that dropped role entries.","solutions":["Define at least one role with user_ids, e.g. `[[projects.myapp.users.roles]] name = \"member\", user_ids = [\"u1\"]`","Remove the empty `[projects.<name>.users]` section entirely if per-user roles aren't needed","Check that role blocks weren't accidentally commented out or merged away"],"exampleFix":"# before\n[projects.myapp.users]\n\n# after\n[projects.myapp.users]\n[projects.myapp.users.roles.member]\nuser_ids = [\"ou_1234\"]","handlingStrategy":"validation","validationCode":"if cfg.Projects[i].Users != nil && len(cfg.Projects[i].Users.Roles) == 0 {\n    return fmt.Errorf(\"project %d: users section present but no roles defined\", i)\n}","typeGuard":"func hasRoles(u *UsersConfig) bool { return u != nil && len(u.Roles) > 0 }","tryCatchPattern":null,"preventionTips":["Don't create a [users] table until you have at least one role ready","Check that role blocks survive comment-outs and config merges","Scaffold new projects from config.example.toml which includes a valid role"],"tags":["config","validation","users","roles"],"backgroundTag":"missing-required-config-field","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}