BoundaryML/baml · error · JsonishError

No markdown blocks found

Error message

No markdown blocks found

What it means

`JsonishError::NoMarkdownBlocksFound` is thrown when the parser is configured to (or attempts to) extract JSON from markdown code fences but no markdown blocks exist in the input. The jsonish parser supports pulling JSON out of fenced code blocks in LLM responses; with none present, this variant fires.

Source

Thrown at baml_language/crates/bex_sap/src/jsonish/mod.rs:19

//! This module implements parsing JSON-like data into a structured representation.
//!
//! The main entry point is the [`parse`] function, which takes a string and returns a [`Value`].
//! This is basically the jsonish equivalent of [`serde_json::from_str`] and [`serde_json::Value`].

mod parser;
mod value;

pub use parser::{ParseOptions, parse};
pub use value::{CompletionState, Fixes, Value};

/// Error type for jsonish parsing failures.
#[derive(Debug, thiserror::Error)]
pub enum JsonishError {
    #[error("Depth limit reached. Likely a circular reference.")]
    DepthLimitReached,
    #[error("No JSON objects found")]
    NoJsonObjectsFound,
    #[error("No markdown blocks found")]
    NoMarkdownBlocksFound,
    #[error("Mismatched brackets")]
    MismatchedBrackets,
    #[error("No collection to consume token: {0:?}")]
    NoCollectionForToken(char),
    #[error("Failed to parse JSON")]
    ParseFailed,
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Update the prompt to explicitly require wrapping JSON in a markdown code fence.
  2. Confirm you actually need fence extraction; if the model emits bare JSON, the plain-JSON path should be used instead.
  3. Strip or normalize the input before parsing to make fence extraction optional.
  4. Check for provider/model version changes that altered output formatting.

Example fix

// before
let v = jsonish::parse(response.text, &opts)?;
// after
// prompt change:
// "Return the JSON wrapped in a ```json code fence."
let v = jsonish::parse(&response.text, &opts)?;
Defensive patterns

Strategy: fallback

Validate before calling

if needs_markdown_extraction && !raw.contains("```") {
    // fall back to plain-JSON extraction path instead
}

Try / catch

match jsonish::parse(&raw, &opts) {
    Ok(v) => Ok(v),
    Err(JsonishError::NoMarkdownBlocksFound) => jsonish::parse(&strip_fences(&raw), &opts),
    Err(e) => Err(e.into()),
}

Prevention

When it happens

Trigger: Calling `bex_sap::jsonish::parse` on output that has no ```-fenced blocks when the extraction path expects one — e.g. the model emitted bare JSON or prose without wrapping it in a code fence.

Common situations: Model changed formatting behavior and stopped wrapping JSON in ```json fences; system prompt doesn't instruct fenced output; a model/provider update altered response formatting.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/28e0507d23f2ee34. Report an issue: GitHub.