{"record":{"id":"c8b6ca6e653b14d3","repo":"slimtoolkit/slim","slug":"expected-s-to-split-by-char-into-two-strings","errorCode":null,"errorMessage":"Expected %s to split by '=' char into two strings, instead got %d strings","messagePattern":"Expected (.+?) to split by '=' char into two strings, instead got (.+?) strings","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/system/os_release.go","lineNumber":82,"sourceCode":"\t\tfieldValue := v.Field(i)\n\t\tfieldType := v.Type().Field(i)\n\t\toriginalName := fieldType.Tag.Get(\"osr\")\n\t\tif key == originalName && fieldValue.Kind() == reflect.String {\n\t\t\tfieldValue.SetString(val)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"Couldn't set key %s, no corresponding struct field found\", key)\n}\n\nfunc parseLine(osrLine string) (string, string, error) {\n\tif osrLine == \"\" {\n\t\treturn \"\", \"\", nil\n\t}\n\n\tvals := strings.Split(osrLine, \"=\")\n\tif len(vals) != 2 {\n\t\treturn \"\", \"\", fmt.Errorf(\"Expected %s to split by '=' char into two strings, instead got %d strings\", osrLine, len(vals))\n\t}\n\tkey := vals[0]\n\tval := stripQuotes(vals[1])\n\treturn key, val, nil\n}\n\nfunc (osr *OsRelease) ParseOsRelease(osReleaseContents []byte) error {\n\tr := bytes.NewReader(osReleaseContents)\n\tscanner := bufio.NewScanner(r)\n\tfor scanner.Scan() {\n\t\tkey, val, err := parseLine(scanner.Text())\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Warning: got an invalid line error parsing /etc/os-release: %s\", err)\n\t\t\tcontinue\n\t\t}\n\t\tif err := osr.setIfPossible(key, val); err != nil {\n\t\t\t//log.Printf(\"Info: %s\\n\",err)\n\t\t\t//note: ignore, printing these messages causes more confusion...","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/system/os_release.go#L64-L100","documentation":"os_release.parseLine splits each os-release line on '=' and requires exactly two parts. Lines with zero or multiple '=' characters (values may legitimately contain '=' unless quoted handling is done before) fail with this error naming the offending line and the number of parts produced.","triggerScenarios":"ParseOsRelease reads a line without exactly one '=' separator, e.g. a blank-with-comment line, a shell fragment, or an unquoted value containing '=' (such as a CPE or URL with '=' in it).","commonSituations":"Custom/os-prober-generated release files with shell syntax; vendor files where the value is unquoted and contains '=' (e.g. BUILD_ID=x=y); accidentally concatenating lsb-release output with os-release.","solutions":["Fix the malformed /etc/os-release line so it is KEY=\"value\" with a single '=' and quoted value","Check for unquoted values containing '=' and add quotes around the value","Regenerate the file from the distro package (e.g. reinstall the 'base-files'/'system-release' package)","As a workaround, pre-process the file to strip invalid lines before parsing"],"exampleFix":"// before (unquoted value with '=')\nBUILD_ID=http://x/?a=1\n// after\nBUILD_ID=\"http://x/?a=1\"","handlingStrategy":"validation","validationCode":"func validOsReleaseLine(line string) bool {\n    line = strings.TrimSpace(line)\n    if line == \"\" || strings.HasPrefix(line, \"#\") { return true }\n    return len(strings.Split(line, \"=\")) == 2\n}","typeGuard":null,"tryCatchPattern":"osr, err := system.ParseOsRelease(path)\nif err != nil && strings.Contains(err.Error(), \"to split by '='\") {\n    log.Warnf(\"skipping malformed os-release line: %v\", err)\n    // sanitize the file or parse remaining valid lines\n}","preventionTips":["Always quote values in os-release style files","Never mix lsb-release shell output into os-release","Regenerate release files from distro packages rather than hand-editing","Validate file format after image builds"],"tags":["parsing","os-release","format"],"backgroundTag":"os-release-line-format","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}