{"record":{"id":"fe680a7aaf7e75c6","repo":"slimtoolkit/slim","slug":"error-parsing-field-s-v","errorCode":null,"errorMessage":"error parsing field - %s (%v)","messagePattern":"error parsing field - (.+?) \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sysidentity/sysidentity.go","lineNumber":537,"sourceCode":"\n\tintFields := [...]*int{\n\t\t&record.LastChangeRaw,\n\t\t&record.MinimumAge,\n\t\t&record.MaximumAge,\n\t\t&record.WarningPeriod,\n\t\t&record.InactiveDays,\n\t\t&record.ExpirationRaw,\n\t}\n\n\tfor idx, val := range intFields {\n\t\tfield := parts[idx+2]\n\t\tif field == \"\" {\n\t\t\t*val = FieldNotSet\n\t\t} else {\n\t\t\tvar err error\n\t\t\t*val, err = strconv.Atoi(field)\n\t\t\tif err != nil {\n\t\t\t\treturn record, fmt.Errorf(\"error parsing field - %s (%v)\", field, err)\n\t\t\t}\n\t\t}\n\t}\n\n\trecord.Password = NewPasswordHash(record.PasswordRaw)\n\tvar err error\n\trecord.LastChangeDate, err = daysToDate(record.LastChangeRaw)\n\tif err != nil {\n\t\treturn record, err\n\t}\n\n\trecord.ExpirationDate, err = daysToDate(record.ExpirationRaw)\n\tif err != nil {\n\t\treturn record, err\n\t}\n\n\treturn record, nil\n}","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/sysidentity/sysidentity.go#L519-L555","documentation":"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.","triggerScenarios":"Parsing a group/identity record where an integer field (e.g. GID) contains characters other than digits, such as a name or stray whitespace.","commonSituations":"Malformed /etc/group entries; automated tooling that wrote a group name where a GID belongs; locale/CRLF contamination introducing invisible bytes.","solutions":["Locate the malformed record and correct the numeric field","Check for CRLF or whitespace: cat -A /etc/group | grep the offending entry","Run: awk -F: '$3 != \"\" && $3 !~ /^[0-9]+$/{print}' /etc/group","Restore the identity file from a known-good copy"],"exampleFix":"// before\ndevs:x:developers:user1\n// after\ndevs:x:1001:user1","handlingStrategy":"validation","validationCode":"func validIdentityNumericFields(line string) bool {\n    for _, f := range strings.Split(line, \":\") {\n        if f == \"\" { continue } // empty allowed -> FieldNotSet\n        if _, err := strconv.Atoi(strings.TrimSpace(f)); err != nil { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"rec, err := parseIdentityRecord(line)\nif err != nil && strings.Contains(err.Error(), \"error parsing field\") {\n    log.Warnf(\"malformed numeric field, skipping: %v\", err)\n    continue\n}","preventionTips":["Ensure generated files use LF endings and no stray whitespace","Quote/escape generated entries in provisioning scripts","Validate identity files in CI before deployment","Trim fields before writing them"],"tags":["parsing","group","identity"],"backgroundTag":"passwd-parse-error","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}