slimtoolkit/slim · error
error parsing GID field - %s (%v)
Error message
error parsing GID field - %s (%v)
What it means
Same parser as the UID case: ParsePasswdRecord converts passwd field 3 (GID) with strconv.Atoi and returns this error when it is not a valid integer. The record is returned partially populated so the caller can inspect which line failed.
Source
Thrown at pkg/sysidentity/sysidentity.go:335
record.Username = parts[0]
record.Password = parts[1]
record.Info = parts[4]
record.Home = parts[5]
record.Shell = strings.TrimSpace(parts[6])
if _, found := NoLoginShells[record.Shell]; found {
record.NoLoginShell = true
}
var err error
record.UID, err = strconv.Atoi(parts[2])
if err != nil {
return record, fmt.Errorf("error parsing UID field - %s (%v)", parts[2], err)
}
record.GID, err = strconv.Atoi(parts[3])
if err != nil {
return record, fmt.Errorf("error parsing GID field - %s (%v)", parts[3], err)
}
return record, nil
}
const (
HasShadowFileRecord = "x"
)
func (ref PasswdRecord) UsesShadow() bool {
if ref.Password == HasShadowFileRecord {
return true
}
return false
}
var NoLoginShells = map[string]struct{}{View on GitHub (pinned to 81940d17fa)
Solutions
- Fix the offending /etc/passwd line so the GID field is numeric
- Find bad lines with: awk -F: '$4 !~ /^[0-9]+$/{print}' /etc/passwd
- Ensure the GID references a real group in /etc/group or create it
- Re-run the identity read; the error names the bad field value
Example fix
// before svc:x:1500:users::/home/svc:/bin/sh // after svc:x:1500:1500::/home/svc:/bin/sh
Defensive patterns
Strategy: validation
Validate before calling
func validPasswdGID(line string) bool {
parts := strings.Split(line, ":")
if len(parts) < 4 { return false }
_, err := strconv.Atoi(parts[3])
return err == nil
} Try / catch
rec, err := sysidentity.ParsePasswdRecord(line)
if err != nil && strings.Contains(err.Error(), "GID field") {
log.Warnf("bad GID in passwd entry: %v", err)
continue
} Prevention
- Always pair new users with numeric GIDs, not group names
- Validate /etc/passwd after automation runs
- Keep GID column strictly numeric
- Check: awk -F: '$4 !~ /^[0-9]+$/{print}' /etc/passwd
When it happens
Trigger: ReadPasswdData -> ParsePasswdRecord on a passwd line whose fourth (GID) field is empty, alphabetic, or otherwise non-numeric.
Common situations: Corrupted or hand-edited /etc/passwd; group name mistakenly placed in the GID column; truncated lines from a bad provisioning script.
Related errors
- error parsing UID field - %s (%v)
- error parsing field - %s (%v)
- malformed Kubernetes workload name
- cannot detect host port
- when using JSON array syntax, arrays must be comprised of st
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/f8494da02c1829fc.
Report an issue: GitHub.