{"record":{"id":"420c6a4a25e015c8","repo":"gastownhall/beads","slug":"failed-to-parse-issue-from-jsonl-w","errorCode":null,"errorMessage":"failed to parse issue from JSONL: %w","messagePattern":"failed to parse issue from JSONL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import.go","lineNumber":286,"sourceCode":"\t\t}\n\n\t\tif rawType, ok := peek[\"_type\"]; ok {\n\t\t\tvar typeStr string\n\t\t\tif err := json.Unmarshal(rawType, &typeStr); err == nil && typeStr == \"memory\" {\n\t\t\t\tvar mem memoryRecord\n\t\t\t\tif err := json.Unmarshal([]byte(line), &mem); err != nil {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to parse memory record: %w\", err)\n\t\t\t\t}\n\t\t\t\tif mem.Key != \"\" && mem.Value != \"\" {\n\t\t\t\t\tmemories = append(memories, mem)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tvar issue types.Issue\n\t\tif err := json.Unmarshal([]byte(line), &issue); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"failed to parse issue from JSONL: %w\", err)\n\t\t}\n\t\tif issue.Status == \"tombstone\" {\n\t\t\tcontinue\n\t\t}\n\t\tapplyImportWispPlane(peek, &issue)\n\t\tissue.SetDefaults()\n\t\tissues = append(issues, &issue)\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to scan JSONL: %w\", err)\n\t}\n\treturn issues, memories, nil\n}\n\n// runImportRecordsClassic is the classic (embedded/direct store) import\n// pipeline over the parsed records: dedup, dry-run classification, memory\n// writes, the batch issue import, the final commit and the issue_prefix\n// reconciliation.","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import.go#L268-L304","documentation":"A JSONL line that is neither a header nor a memory record is unmarshaled into types.Issue, and that unmarshal failed. Since the line is valid JSON, the problem is the payload not conforming to the Issue schema (wrong field types, unknown enum values, etc.).","triggerScenarios":"`bd import` reads a record whose fields collide with types.Issue — e.g. `priority` as a string \"P1\" instead of a number, `status` not a known string, `labels` as an object instead of an array, or an entirely different JSON document passed by mistake.","commonSituations":"Importing JSONL exported by another tool or an older beads version; hand-written issues with wrong field types; accidentally passing a JSON config file to `bd import`.","solutions":["Fix the reported field's JSON type to match the Issue schema (e.g. numeric priority, array labels)","Re-export from the source repo with `bd export -o file.jsonl` to get canonical records","Remove unrelated JSON documents from the stream","Check beads release notes for Issue schema changes if the export predates your binary"],"exampleFix":"// before\n{\"id\":\"bd-1\",\"title\":\"Bug\",\"priority\":\"P1\"}\n// after\n{\"id\":\"bd-1\",\"title\":\"Bug\",\"priority\":1,\"status\":\"open\"}","handlingStrategy":"validation","validationCode":"jq -c 'select(._type==null or ._type!=\"memory\") | (.priority|type==\"number\") and (.labels|type==\"array\")' file.jsonl","typeGuard":null,"tryCatchPattern":"if ! bd import data.jsonl 2>err.log; then\n  grep 'failed to parse issue from JSONL' err.log   # fix field types on that line\nfi","preventionTips":["Follow the canonical Issue schema: numeric priority, string status, array labels","Always source imports from `bd export` output rather than third-party generators","Dry-run imports (`bd import --dry-run`) to catch schema problems before writing","Check release notes for Issue schema changes between bd versions"],"tags":["json","parsing","schema"],"backgroundTag":"record-schema-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}