slimtoolkit/slim · error

error parsing field - %s (%v)

Error message

error parsing field - %s (%v)

What it means

A generic numeric-field parser (used for /etc/group-style records, e.g. GID or other integer fields) reports 'error parsing field' when strconv.Atoi fails on a non-empty field value. Empty fields are allowed (set to FieldNotSet), so this error only fires on non-numeric content.

Source

Thrown at pkg/sysidentity/sysidentity.go:537

	intFields := [...]*int{
		&record.LastChangeRaw,
		&record.MinimumAge,
		&record.MaximumAge,
		&record.WarningPeriod,
		&record.InactiveDays,
		&record.ExpirationRaw,
	}

	for idx, val := range intFields {
		field := parts[idx+2]
		if field == "" {
			*val = FieldNotSet
		} else {
			var err error
			*val, err = strconv.Atoi(field)
			if err != nil {
				return record, fmt.Errorf("error parsing field - %s (%v)", field, err)
			}
		}
	}

	record.Password = NewPasswordHash(record.PasswordRaw)
	var err error
	record.LastChangeDate, err = daysToDate(record.LastChangeRaw)
	if err != nil {
		return record, err
	}

	record.ExpirationDate, err = daysToDate(record.ExpirationRaw)
	if err != nil {
		return record, err
	}

	return record, nil
}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Locate the malformed record and correct the numeric field
  2. Check for CRLF or whitespace: cat -A /etc/group | grep the offending entry
  3. Run: awk -F: '$3 != "" && $3 !~ /^[0-9]+$/{print}' /etc/group
  4. Restore the identity file from a known-good copy

Example fix

// before
devs:x:developers:user1
// after
devs:x:1001:user1
Defensive patterns

Strategy: validation

Validate before calling

func validIdentityNumericFields(line string) bool {
    for _, f := range strings.Split(line, ":") {
        if f == "" { continue } // empty allowed -> FieldNotSet
        if _, err := strconv.Atoi(strings.TrimSpace(f)); err != nil { return false }
    }
    return true
}

Try / catch

rec, err := parseIdentityRecord(line)
if err != nil && strings.Contains(err.Error(), "error parsing field") {
    log.Warnf("malformed numeric field, skipping: %v", err)
    continue
}

Prevention

When it happens

Trigger: Parsing a group/identity record where an integer field (e.g. GID) contains characters other than digits, such as a name or stray whitespace.

Common situations: Malformed /etc/group entries; automated tooling that wrote a group name where a GID belongs; locale/CRLF contamination introducing invisible bytes.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/fe680a7aaf7e75c6. Report an issue: GitHub.