{"record":{"id":"9604d4aee871ca40","repo":"BoundaryML/baml","slug":"no-markdown-blocks-found-parser","errorCode":null,"errorMessage":"No markdown blocks found","messagePattern":"No markdown blocks found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"engine/baml-lib/jsonish/src/jsonish/parser/markdown_parser.rs","lineNumber":128,"sourceCode":"                            \"<unspecified>\"\n                        }\n                    }\n                    .to_string(),\n                    v,\n                ));\n            }\n            Err(e) => {\n                log::debug!(\"Error parsing markdown block: Tag: {tag}\\n{e:?}\");\n            }\n        };\n\n        if !should_loop {\n            break;\n        }\n    }\n\n    if values.is_empty() {\n        anyhow::bail!(\"No markdown blocks found\")\n    } else {\n        if !remaining.trim().is_empty() {\n            values.push(MarkdownResult::String(remaining.to_string()));\n        }\n        Ok(values)\n    }\n}\n\n#[cfg(test)]\nmod test {\n    use baml_types::CompletionState;\n    use test_log::test;\n\n    use super::*;\n    use crate::jsonish::Value;\n\n    #[test]\n    fn basic_parse() -> Result<()> {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/jsonish/src/jsonish/parser/markdown_parser.rs#L110-L146","documentation":"The markdown parser scans the input for fenced code blocks (``` or ~~~ style) and returns 'No markdown blocks found' when none were detected. It exists so JSON can be extracted from ```json fences; no fences means this parser has nothing to return.","triggerScenarios":"Calling markdown_parser::parse (or the jsonish pipeline routing to it) on text with zero fence-like code blocks, e.g. raw JSON without backticks or plain prose.","commonSituations":"Prompt asked the model for code blocks but the model returned bare JSON or plain text; model used a single backtick or indented code without fences.","solutions":["Don't force the markdown parser for unfenced content — let the plain JSON parser handle it","Check whether the model wrapped output in a non-standard fence and normalize it (e.g. convert ~~~ to ```)","Update the prompt to require ```json fenced output","Catch the error and retry with a stricter formatting instruction"],"exampleFix":"// before\nlet blocks = markdown_parser::parse(text).expect(\"fences\");\n// after\nlet blocks = match markdown_parser::parse(text) {\n    Ok(b) => b,\n    Err(_) => vec![MarkdownResult::String(text.to_string())],\n};","handlingStrategy":"fallback","validationCode":"fn has_fence(s: &str) -> bool { s.contains(\"```\") || s.contains(\"~~~\") }","typeGuard":null,"tryCatchPattern":"match markdown_parser::parse(text) {\n    Err(_) | Ok(ref b) if b.is_empty() => vec![MarkdownResult::String(text.to_string())],\n    Ok(b) => b,\n}","preventionTips":["Prompt the model to wrap output in ```json fences","Normalize non-standard fences (~~~ -> ```) before parsing","Route unfenced JSON to the plain JSON parser instead"],"tags":["markdown","parsing","llm-output"],"backgroundTag":"json-parse-error","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}