{"record":{"id":"27fa3b12a39f3e43","repo":"BoundaryML/baml","slug":"no-json-objects-found-fixing-parser","errorCode":null,"errorMessage":"No JSON objects found","messagePattern":"No JSON objects found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser.rs","lineNumber":55,"sourceCode":"                for _ in 0..increments {\n                    chars.next();\n                }\n            }\n            Err(e) => {\n                return Err(e);\n            }\n        }\n    }\n\n    // If we still have a collection open, close it\n    while !state.collection_stack.is_empty() {\n        state.complete_collection(CompletionState::Incomplete);\n    }\n\n    // Determine what to return.\n\n    match state.completed_values.len() {\n        0 => Err(anyhow::anyhow!(\"No JSON objects found\")),\n        1 => state\n            .completed_values\n            .pop()\n            .map(|(_name, value, fixes)| Ok(vec![(value, fixes)]))\n            .unwrap_or(Err(anyhow::anyhow!(\"Failed to pop completed value\"))),\n        _ => {\n            if state.completed_values.iter().all(|f| f.0 == \"string\") {\n                // If all the values are strings, return them as an array of strings\n                Ok(vec![(\n                    Value::Array(\n                        state\n                            .completed_values\n                            .into_iter()\n                            .map(|f| {\n                                let completion_state = f.1.completion_state().clone();\n                                Value::FixedJson(f.1.into(), f.2)\n                            })\n                            .collect(),","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser.rs#L37-L73","documentation":"The fixing (partial/streaming JSON) parser tracks completed values as it scans the input; when parsing finishes and zero values were completed, the public parse() returns 'No JSON objects found'. This happens for input that contains no salvageable object/array at all.","triggerScenarios":"Calling fixing_parser::parse with an empty string, plain prose, or input where no object/array was ever opened/completed (0 completed_values).","commonSituations":"Streaming chunks that so far contain only whitespace or explanatory text before the JSON begins; empty LLM completions.","solutions":["Check the input for any '{' or '[' before invoking the fixing parser","Wait for a chunk that actually contains JSON start content before parsing partials","Wrap in try/catch and keep the previous successful partial value","Pre-filter the response (e.g. strip prose, extract fenced blocks) before parsing"],"exampleFix":"// before\nlet vals = fixing_parser::parse(input)?;\n// after\nif input.trim_start().starts_with(['{', '[']) {\n    let vals = fixing_parser::parse(input)?;\n}","handlingStrategy":"validation","validationCode":"fn worth_fixing(s: &str) -> bool { s.contains('{') || s.contains('[') }","typeGuard":null,"tryCatchPattern":"match fixing_parser::parse(chunk) {\n    Err(e) if e.to_string().contains(\"No JSON objects\") => Ok(last_good_value.clone()),\n    other => other,\n}","preventionTips":["Skip empty/prose-only chunks before partial parsing","Track the last successfully parsed partial as a fallback","Wait for the first '{' or '[' in the stream before parsing"],"tags":["json","streaming","partial-parsing"],"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"}