{"record":{"id":"8e5e365859b8fe05","repo":"zed-industries/zed","slug":"unexpected-heading-level-level","errorCode":null,"errorMessage":"Unexpected heading level: {level}","messagePattern":"Unexpected heading level: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction/src/example_spec.rs","lineNumber":349,"sourceCode":"                        Section::EditHistory\n                    } else if title.eq_ignore_ascii_case(CURSOR_POSITION_HEADING) {\n                        Section::CursorPosition\n                    } else if title.eq_ignore_ascii_case(EXPECTED_PATCH_HEADING) {\n                        Section::ExpectedPatch\n                    } else if title.eq_ignore_ascii_case(REJECTED_PATCH_HEADING) {\n                        Section::RejectedPatch\n                    } else {\n                        Section::Other\n                    };\n                }\n                Event::End(TagEnd::Heading(HeadingLevel::H3)) => {\n                    mem::take(&mut text);\n                }\n                Event::End(TagEnd::Heading(HeadingLevel::H4)) => {\n                    mem::take(&mut text);\n                }\n                Event::End(TagEnd::Heading(level)) => {\n                    anyhow::bail!(\"Unexpected heading level: {level}\");\n                }\n                Event::Start(Tag::CodeBlock(kind)) => {\n                    if current_section == Section::EditHistory\n                        && text.trim() == ACCEPTED_PREDICTION_MARKER\n                    {\n                        next_edit_predicted = true;\n                    }\n                    text.clear();\n                    match kind {\n                        CodeBlockKind::Fenced(info) => {\n                            block_info = info;\n                        }\n                        CodeBlockKind::Indented => {\n                            anyhow::bail!(\"Unexpected indented codeblock\");\n                        }\n                    };\n                }\n                Event::Start(_) => {","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction/src/example_spec.rs#L331-L367","documentation":"Edit-prediction example specs are parsed with pulldown-cmark into a structured Section state machine; heading End events for H3/H4 are consumed as section boundaries, and any other heading level reaching the catch-all `Event::End(TagEnd::Heading(level))` arm aborts parsing of the whole spec (example_spec.rs:349).","triggerScenarios":"Editing an example-spec markdown file and using `#`, `##`, `#####`, or `######` headings where only `###` (sections) and `####` (subsections) are allowed by the parser.","commonSituations":"Contributors adding spec sections with the wrong heading depth; markdown auto-formatting or editors promoting/demoting headings; content pasted from other docs with deeper heading trees.","solutions":["Change the offending heading to `###` or `####` so the parser recognizes the section boundary.","Re-run the spec parser / test suite locally to confirm the file is accepted.","Add a lint or CI check that rejects unsupported heading levels in example specs."],"exampleFix":"##### Uncommitted diff      // before — H5 hits catch-all arm\n\n#### Uncommitted diff       // after — H4 is consumed as a subsection boundary","handlingStrategy":"validation","validationCode":"# reject unsupported heading levels before committing spec files\ngrep -nE '^#{1,2} |^#{5,6} ' examples/*.md && echo \"only ### and #### allowed\" || echo OK","typeGuard":"fn is_supported_heading(level: HeadingLevel) -> bool {\n    matches!(level, HeadingLevel::H3 | HeadingLevel::H4)\n}","tryCatchPattern":null,"preventionTips":["Document the H3/H4-only convention at the top of each spec directory.","Run the spec parser as a CI check on every spec change.","Disable editor auto-formatting that can shift heading levels in spec files."],"tags":["edit-prediction","markdown","example-spec","parsing"],"backgroundTag":"markdown-parsing-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}