{"record":{"id":"0a42b3dcf1f60380","repo":"unclecode/crawl4ai","slug":"the-fit-markdown-attribute-is-deprecated-and-has-0a42b3","errorCode":null,"errorMessage":"The 'fit_markdown' attribute is deprecated and has been removed. Please use 'markdown.fit_markdown' instead.","messagePattern":"The 'fit_markdown' attribute is deprecated and has been removed\\. Please use 'markdown\\.fit_markdown' instead\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"warning","filePath":"crawl4ai/models.py:232","lineNumber":5435,"sourceCode":"        deprecated and they should use 'markdown' instead.\n        \"\"\"\n        raise AttributeError(\n            \"The 'markdown_v2' attribute is deprecated and has been removed. \"\n            \"\"\"Please use 'markdown' instead, which now returns a MarkdownGenerationResult, with\n            following properties:\n            - raw_markdown: The raw markdown string\n            - markdown_with_citations: The markdown string with citations\n            - references_markdown: The markdown string with references\n            - fit_markdown: The markdown string with fit text\n            \"\"\"\n        )\n    \n    @property\n    def fit_markdown(self):\n        \"\"\"\n        Deprecated property that raises an AttributeError when accessed.\n        \"\"\"\n        raise AttributeError(\n            \"The 'fit_markdown' attribute is deprecated and has been removed. \"\n            \"Please use 'markdown.fit_markdown' instead.\"\n        )\n    \n    @property\n    def fit_html(self):\n        \"\"\"\n        Deprecated property that raises an AttributeError when accessed.\n        \"\"\"\n        raise AttributeError(\n            \"The 'fit_html' attribute is deprecated and has been removed. \"\n            \"Please use 'markdown.fit_html' instead.\"\n        )\n\n    def model_dump(self, *args, **kwargs):\n        \"\"\"\n        Override model_dump to include the _markdown private attribute in serialization.\n        ","sourceCodeStart":5417,"sourceCodeEnd":5453,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/deploy/docker/c4ai-code-context.md#L5417-L5453","documentation":"CrawlResult.fit_markdown used to return the PruningContentFilter-filtered ('fit') markdown directly on the result object. In the new API the fit output lives inside the MarkdownGenerationResult returned by result.markdown, so the old property is a tombstone that raises AttributeError pointing you at markdown.fit_markdown.","triggerScenarios":"Reading result.fit_markdown after a crawl where a content filter (e.g. PruningContentFilter) was configured in CrawlerRunConfig; older code written before the markdown refactor.","commonSituations":"Upgrading crawl4ai and hitting the markdown refactor; RAG pipelines that stored fit_markdown for chunking; examples from blog posts targeting the old attribute layout.","solutions":["Use result.markdown.fit_markdown instead","Make sure a content filter is actually configured (e.g. CrawlerRunConfig(content_filter=PruningContentFilter(...), cache_mode=...)) — otherwise markdown.fit_markdown may be empty"],"exampleFix":"// before\nfit = result.fit_markdown\n// after\nfit = result.markdown.fit_markdown\n","handlingStrategy":"type-guard","validationCode":"def get_fit(result):\n    md = getattr(result, \"markdown\", None)\n    if md is not None:\n        return getattr(md, \"fit_markdown\", None) or getattr(md, \"raw_markdown\", \"\")\n    return getattr(result, \"fit_markdown\", \"\")","typeGuard":"def has_fit_markdown(result) -> bool:\n    md = getattr(result, \"markdown\", None)\n    return md is not None and bool(getattr(md, \"fit_markdown\", None))","tryCatchPattern":"try:\n    fit = result.fit_markdown\nexcept AttributeError:\n    fit = result.markdown.fit_markdown\n","preventionTips":["Always read fit content through result.markdown.fit_markdown in new code","Confirm content_filter is set in CrawlerRunConfig, otherwise fit_markdown is empty","Search for fit_markdown usages when upgrading crawl4ai"],"tags":["crawl4ai","deprecation","content-filter","fit-markdown"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}