unclecode/crawl4ai · warning · AttributeError

The 'markdown_v2' attribute is deprecated and has been remov

Error message

The 'markdown_v2' attribute is deprecated and has been removed. Please use 'markdown' instead, which now returns a MarkdownGenerationResult, with
            following properties:
            - raw_markdown: The raw markdown string
            - markdown_with_citations: The markdown string with citations
            - references_markdown: The markdown string with references
            - fit_markdown: The markdown string with fit text
            

What it means

CrawlResult previously exposed markdown_v2, which returned a structured MarkdownGenerationResult; that API was renamed so that the plain markdown property now returns MarkdownGenerationResult. Accessing markdown_v2 raises an intentional AttributeError explaining the new shape (raw_markdown, markdown_with_citations, references_markdown, fit_markdown).

Source

Thrown at crawl4ai/models.py:216:5419

            return None
        return StringCompatibleMarkdown(self._markdown)
    
    @markdown.setter
    def markdown(self, value):
        """
        Setter for the markdown property.
        """
        self._markdown = value
    
    @property
    def markdown_v2(self):
        """
        Deprecated property that raises an AttributeError when accessed.

        This property exists to inform users that 'markdown_v2' has been
        deprecated and they should use 'markdown' instead.
        """
        raise AttributeError(
            "The 'markdown_v2' attribute is deprecated and has been removed. "
            """Please use 'markdown' instead, which now returns a MarkdownGenerationResult, with
            following properties:
            - raw_markdown: The raw markdown string
            - markdown_with_citations: The markdown string with citations
            - references_markdown: The markdown string with references
            - fit_markdown: The markdown string with fit text
            """
        )
    
    @property
    def fit_markdown(self):
        """
        Deprecated property that raises an AttributeError when accessed.
        """
        raise AttributeError(
            "The 'fit_markdown' attribute is deprecated and has been removed. "
            "Please use 'markdown.fit_markdown' instead."

View on GitHub (pinned to 7e80152142)

Solutions

  1. Replace result.markdown_v2 with result.markdown — it now returns the same MarkdownGenerationResult
  2. Use the specific field you need: result.markdown.raw_markdown, result.markdown.fit_markdown, result.markdown.markdown_with_citations
  3. If you only want the plain string, str(result.markdown) or result.markdown.raw_markdown

Example fix

// before
md = result.markdown_v2.raw_markdown
// after
md = result.markdown.raw_markdown
Defensive patterns

Strategy: type-guard

Validate before calling

def get_markdown_v2_style(result):
    # modern API: markdown is MarkdownGenerationResult
    return result.markdown  # use .raw_markdown / .fit_markdown on it

Type guard

def has_markdown_result(result) -> bool:
    md = getattr(result, "markdown", None)
    return md is not None and hasattr(md, "raw_markdown") and hasattr(md, "fit_markdown")

Try / catch

try:
    md = result.markdown_v2
except AttributeError:
    md = result.markdown  # new MarkdownGenerationResult

Prevention

When it happens

Trigger: Accessing result.markdown_v2 on a CrawlResult after upgrading crawl4ai; code written against the 0.5.x-era API where markdown_v2 coexisted with the legacy string markdown.

Common situations: Upgrading crawl4ai across the markdown/markdown_v2 unification; tutorials or cookbook code referencing markdown_v2; generic code doing getattr(result, 'markdown_v2', ...) which still triggers the property (the property itself raises, so getattr without default does not protect you).

Related errors


AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14). Data as JSON: /api/errors/382aec666be41185. Report an issue: GitHub.