{"record":{"id":"76bb2cec4b03c728","repo":"kubernetes/kops","slug":"error-looking-up-group-q-v","errorCode":null,"errorMessage":"error looking up group %q: %v","messagePattern":"error looking up group %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/files_owner.go","lineNumber":56,"sourceCode":"\tactualUserID := int(stat.Sys().(*syscall.Stat_t).Uid)\n\tuserID := actualUserID\n\tif owner != \"\" {\n\t\tuser, err := LookupUser(owner) // user.Lookup(owner)\n\t\tif err != nil {\n\t\t\treturn changed, fmt.Errorf(\"error looking up user %q: %v\", owner, err)\n\t\t}\n\t\tif user == nil {\n\t\t\treturn changed, fmt.Errorf(\"user %q not found\", owner)\n\t\t}\n\t\tuserID = user.Uid\n\t}\n\n\tactualGroupID := int(stat.Sys().(*syscall.Stat_t).Gid)\n\tgroupID := actualGroupID\n\tif groupName != \"\" {\n\t\tgroup, err := LookupGroup(groupName)\n\t\tif err != nil {\n\t\t\treturn changed, fmt.Errorf(\"error looking up group %q: %v\", groupName, err)\n\t\t}\n\t\tif group == nil {\n\t\t\treturn changed, fmt.Errorf(\"group %q not found\", groupName)\n\t\t}\n\t\tgroupID = group.Gid\n\t}\n\n\tif actualUserID == userID && actualGroupID == groupID {\n\t\treturn changed, nil\n\t}\n\n\tklog.Infof(\"Changing file owner/group for %q to %s:%s\", destPath, owner, groupName)\n\terr = os.Lchown(destPath, userID, groupID)\n\tif err != nil {\n\t\treturn changed, fmt.Errorf(\"error setting file owner/group for %q: %v\", destPath, err)\n\t}\n\tchanged = true\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/files_owner.go#L38-L74","documentation":"EnsureFileOwner resolves the requested group name via LookupGroup before chowning a file. When the group lookup fails with an error (as opposed to returning nil), the function wraps and returns it. This typically means the group database (e.g. /etc/group, NSS) could not be consulted or the lookup implementation failed.","triggerScenarios":"RenderLocal on a file task whose group field names a group that cannot be resolved; LookupGroup(groupName) returns a non-nil error (parse failure, NSS backend failure, or OS group-database error).","commonSituations":"Corrupt or unreadable /etc/group on the admin machine; running in a container without the group entry; NSS misconfiguration; typo in group name in cluster spec.","solutions":["Check `getent group <name>` to reproduce the lookup failure","Create the group (`sudo groupadd <name>`) or correct the group field in the spec","Inspect /etc/group and NSS config (/etc/nsswitch.conf) for corruption or misconfiguration","Set group to empty string to leave the group unchanged"],"exampleFix":"// before\nsudo chown test /etc/group  # corrupted db\n// after\nsudo groupadd <missing-group>  # or fix /etc/group and nsswitch.conf","handlingStrategy":"validation","validationCode":"if _, err := user.LookupGroup(group); err != nil { return fmt.Errorf(\"group %q cannot be resolved locally: %v\", group, err) }","typeGuard":null,"tryCatchPattern":"if err != nil { if strings.Contains(err.Error(), \"looking up group\") { log.Warnf(\"group lookup failed, skipping chown: %v\", err); return nil } return err }","preventionTips":["Verify /etc/group and nsswitch.conf health on build hosts","Check `getent group <name>` works before running updates","Use numeric GIDs only if lookups are unreliable in your environment"],"tags":["filesystem","permissions","group-lookup"],"backgroundTag":"group-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}