{"id":"d24134b9d0070a9e","repo":"docker/cli","slug":"invalid-utf8-bytes-at-line-d-v","errorCode":null,"errorMessage":"invalid utf8 bytes at line %d: %v","messagePattern":"invalid utf8 bytes at line (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/kvfile/kvfile.go","lineNumber":88,"sourceCode":"\n// ParseFromReader parses a line-delimited key/value pairs separated by equal sign.\n// It accepts a lookupFn to lookup default values for keys that do not define\n// a value. An error is produced if parsing failed, the content contains invalid\n// UTF-8 characters, or a key contains whitespaces.\nfunc ParseFromReader(r io.Reader, lookupFn func(key string) (value string, found bool)) ([]string, error) {\n\treturn parseKeyValueFile(r, lookupFn)\n}\n\nconst whiteSpaces = \" \\t\"\n\nfunc parseKeyValueFile(r io.Reader, lookupFn func(string) (string, bool)) ([]string, error) {\n\tlines := []string{}\n\tscanner := bufio.NewScanner(r)\n\tutf8bom := []byte{0xEF, 0xBB, 0xBF}\n\tfor currentLine := 1; scanner.Scan(); currentLine++ {\n\t\tscannedBytes := scanner.Bytes()\n\t\tif !utf8.Valid(scannedBytes) {\n\t\t\treturn []string{}, fmt.Errorf(\"invalid utf8 bytes at line %d: %v\", currentLine, scannedBytes)\n\t\t}\n\t\t// We trim UTF8 BOM\n\t\tif currentLine == 1 {\n\t\t\tscannedBytes = bytes.TrimPrefix(scannedBytes, utf8bom)\n\t\t}\n\t\t// trim the line from all leading whitespace first. trailing whitespace\n\t\t// is part of the value, and is kept unmodified.\n\t\tline := strings.TrimLeftFunc(string(scannedBytes), unicode.IsSpace)\n\n\t\tif len(line) == 0 || line[0] == '#' {\n\t\t\t// skip empty lines and comments (lines starting with '#')\n\t\t\tcontinue\n\t\t}\n\n\t\tkey, _, hasValue := strings.Cut(line, \"=\")\n\t\tif len(key) == 0 {\n\t\t\treturn []string{}, fmt.Errorf(\"no variable name on line '%s'\", line)\n\t\t}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/pkg/kvfile/kvfile.go#L70-L106","documentation":"Error \"invalid utf8 bytes at line %d: %v\" thrown in docker/cli.","triggerScenarios":"Thrown at pkg/kvfile/kvfile.go:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}