{"record":{"id":"8d41e5c5fda8a5bd","repo":"BoundaryML/baml","slug":"no-json-objects-found","errorCode":null,"errorMessage":"No JSON objects found","messagePattern":"No JSON objects found","errorType":"error_code","errorClass":"JsonishError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_sap/src/jsonish/mod.rs","lineNumber":17,"sourceCode":"//! This module implements parsing JSON-like data into a structured representation.\n//!\n//! The main entry point is the [`parse`] function, which takes a string and returns a [`Value`].\n//! This is basically the jsonish equivalent of [`serde_json::from_str`] and [`serde_json::Value`].\n\nmod parser;\nmod value;\n\npub use parser::{ParseOptions, parse};\npub use value::{CompletionState, Fixes, Value};\n\n/// Error type for jsonish parsing failures.\n#[derive(Debug, thiserror::Error)]\npub enum JsonishError {\n    #[error(\"Depth limit reached. Likely a circular reference.\")]\n    DepthLimitReached,\n    #[error(\"No JSON objects found\")]\n    NoJsonObjectsFound,\n    #[error(\"No markdown blocks found\")]\n    NoMarkdownBlocksFound,\n    #[error(\"Mismatched brackets\")]\n    MismatchedBrackets,\n    #[error(\"No collection to consume token: {0:?}\")]\n    NoCollectionForToken(char),\n    #[error(\"Failed to parse JSON\")]\n    ParseFailed,\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_sap/src/jsonish/mod.rs#L1-L28","documentation":"`JsonishError::NoJsonObjectsFound` is returned when the jsonish extractor scans the input text and finds no JSON object it can extract. The parser attempts to locate JSON within free-form LLM output, and if nothing resembling a JSON object is present, this variant is thrown.","triggerScenarios":"Calling `bex_sap::jsonish::parse` on text that contains no `{`...`}` (or extractable JSON) content at all — e.g. the model replied with plain prose or an apology instead of JSON.","commonSituations":"Model refuses the task and returns natural language; the prompt never asked for JSON output; output was truncated before any JSON appeared; wrong field of the response is being parsed.","solutions":["Log the raw input and confirm the model actually produced JSON; fix the prompt to require JSON output.","Check you are parsing the correct response field (content vs. reasoning vs. tool output).","Add a fallback: retry the request or use a repair prompt asking the model to emit valid JSON.","Verify truncation settings (max tokens) aren't cutting the JSON off before it starts."],"exampleFix":"// before\nlet v = jsonish::parse(response.text, &opts)?;\n// after\nlet v = match jsonish::parse(&response.text, &opts) {\n    Ok(v) => v,\n    Err(JsonishError::NoJsonObjectsFound) => retry_with_json_repair_prompt(&response.text)?,\n    Err(e) => return Err(e.into()),\n};","handlingStrategy":"fallback","validationCode":"if !raw.contains('{') && !raw.contains('[') {\n    return Err(\"model produced no JSON at all; retry with stricter prompt\");\n}","typeGuard":null,"tryCatchPattern":"match jsonish::parse(&raw, &opts) {\n    Ok(v) => Ok(v),\n    Err(JsonishError::NoJsonObjectsFound) => retry_with_json_repair_prompt(&raw),\n    Err(e) => Err(e.into()),\n}","preventionTips":["Always instruct the model to respond with JSON only.","Use provider-level JSON mode when available.","Parse the correct response field and log raw output on failure."],"tags":["parsing","json","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-14T05:17:10.506Z"}