{"record":{"id":"3e3e19e812899a3f","repo":"gastownhall/beads","slug":"unexpected-porcelain-status-record-q","errorCode":null,"errorMessage":"unexpected porcelain status record %q","messagePattern":"unexpected porcelain status record %q","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":1130,"sourceCode":"\t\t_, err = hasher.Write([]byte{0})\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn fmt.Sprintf(\"%x\", hasher.Sum(nil)), nil\n}\n\nfunc fingerprintWorktreeStatusPaths(worktreePath, status string) (string, error) {\n\trecords := strings.Split(status, \"\\x00\")\n\tpathSet := make(map[string]struct{})\n\tfor index := 0; index < len(records); index++ {\n\t\trecord := records[index]\n\t\tif record == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif len(record) < 4 || record[2] != ' ' {\n\t\t\treturn \"\", fmt.Errorf(\"unexpected porcelain status record %q\", record)\n\t\t}\n\t\tcode := record[:2]\n\t\tpathSet[record[3:]] = struct{}{}\n\t\tif strings.ContainsAny(code, \"RC\") {\n\t\t\tindex++\n\t\t\tif index >= len(records) || records[index] == \"\" {\n\t\t\t\treturn \"\", fmt.Errorf(\"missing source path for porcelain rename/copy record %q\", record)\n\t\t\t}\n\t\t\tpathSet[records[index]] = struct{}{}\n\t\t}\n\t}\n\n\tpaths := make([]string, 0, len(pathSet))\n\tfor path := range pathSet {\n\t\tpaths = append(paths, path)\n\t}\n\tsort.Strings(paths)\n","sourceCodeStart":1112,"sourceCodeEnd":1148,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L1112-L1148","documentation":"bd parses raw `git status --porcelain=v1 -z` output when fingerprinting target changes. Each record must be at least 4 bytes with a space at offset 2 (`XY path`). This error means git returned a record in an unexpected format, so bd refuses to guess and aborts the fingerprint — usually a git version/behavior mismatch or corrupted capture of the status output.","triggerScenarios":"fingerprintWorktreeStatusPaths encountering a -z status record shorter than 4 chars or with a byte other than ' ' at index 2 — e.g. a very new git emitting newer porcelain fields, or output corruption (NUL handling bug, interleaved output).","commonSituations":"Extremely old or patched/newer git builds diverging from porcelain v1; running against a git shim/wrapper that mangles output; unexpected quote handling around exotic filenames in custom git builds.","solutions":["Run `git version` and `git -C <worktree> status --porcelain=v1 -z` and inspect raw records (e.g. pipe through `od -c`) to spot the malformed line","Upgrade (or downgrade) git to a mainstream release ≥2.x so porcelain v1 -z output matches expectations","Report the exact record text to bd maintainers if git's output looks standard — the parser may need updating"],"exampleFix":"// inspect raw records\ngit -C ../mywt status --porcelain=v1 -z | od -c | head\n// upgrade git\nbrew upgrade git  # or apt-get install -y git","handlingStrategy":"try-catch","validationCode":"out, err := exec.Command(\"git\", \"-C\", wt, \"status\", \"--porcelain=v1\", \"-z\").Output()\nif err != nil || strings.Count(string(out), \"\\x00\") == 0 {\n    return fmt.Errorf(\"status output missing or suspicious\")\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"unexpected porcelain status record\") {\n    // dump raw status via od -c, check git version, report upstream\n    t := \"git -C <wt> status --porcelain=v1 -z | od -c\"\n}","preventionTips":["Use a mainstream git >= 2.x; avoid git wrappers/shims that rewrite output","Pin git versions in CI where bd worktree commands run","Sanity-check raw -z status output when upgrading toolchains"],"tags":["git","parsing","porcelain"],"backgroundTag":"porcelain-status-parse-error","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}