{"record":{"id":"7a9ab0e5ac582845","repo":"crewAIInc/crewAI","slug":"formats-can-only-contain-markdown-or-html","errorCode":null,"errorMessage":"formats can only contain 'markdown' or 'html'","messagePattern":"formats can only contain 'markdown' or 'html'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/hyperbrowser_load_tool/hyperbrowser_load_tool.py","lineNumber":88,"sourceCode":"    def _prepare_params(params: dict[str, Any]) -> dict[str, Any]:\n        \"\"\"Prepare session and scrape options parameters.\"\"\"\n        try:\n            from hyperbrowser.models.scrape import (  # type: ignore[import-untyped]\n                ScrapeOptions,\n            )\n            from hyperbrowser.models.session import (  # type: ignore[import-untyped]\n                CreateSessionParams,\n            )\n        except ImportError as e:\n            raise ImportError(\n                \"`hyperbrowser` package not found, please run `pip install hyperbrowser`\"\n            ) from e\n\n        if \"scrape_options\" in params:\n            if \"formats\" in params[\"scrape_options\"]:\n                formats = params[\"scrape_options\"][\"formats\"]\n                if not all(fmt in [\"markdown\", \"html\"] for fmt in formats):\n                    raise ValueError(\"formats can only contain 'markdown' or 'html'\")\n\n        if \"session_options\" in params:\n            params[\"session_options\"] = CreateSessionParams(**params[\"session_options\"])\n        if \"scrape_options\" in params:\n            params[\"scrape_options\"] = ScrapeOptions(**params[\"scrape_options\"])\n        return params\n\n    def _extract_content(self, data: Any | None) -> str:\n        \"\"\"Extract content from response data.\"\"\"\n        content = \"\"\n        if data:\n            content = data.markdown or data.html or \"\"\n        return content\n\n    def _run(\n        self,\n        url: str,\n        operation: Literal[\"scrape\", \"crawl\"] = \"scrape\",","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/hyperbrowser_load_tool/hyperbrowser_load_tool.py#L70-L106","documentation":"ValueError raised by HyperbrowserLoadTool._prepare_params when the 'formats' list inside scrape_options contains anything other than 'markdown' or 'html'. The tool validates the LLM/caller-supplied params dict before converting it into typed ScrapeOptions, whitelisting exactly two format strings.","triggerScenarios":"Passing scrape_options={'formats': ['markdown', 'screenshot']} or ['rawHtml'], ['json'], or even ['Markdown'] (case-sensitive whitelist) in the params handed to the tool's run method.","commonSituations":"Copy-pasting scrape_options from Firecrawl docs (which support rawHtml, screenshot, links) into the Hyperbrowser tool; LLM agents inventing formats; case mismatches.","solutions":["Use only 'markdown' and/or 'html' in scrape_options.formats.","Strip unsupported entries before invoking: fmts = [f for f in fmts if f in ('markdown','html')].","Get content type from the response via the tool's own extraction (data.markdown / data.html) instead of requesting extra formats."],"exampleFix":"# before\nparams = {'scrape_options': {'formats': ['rawHtml', 'markdown']}}\n\n# after\nparams = {'scrape_options': {'formats': ['html', 'markdown']}}","handlingStrategy":"validation","validationCode":"ALLOWED_FORMATS = {'markdown', 'html'}\nso = params.setdefault('scrape_options', {})\nfmts = so.get('formats', ['markdown'])\nso['formats'] = [f for f in fmts if f in ALLOWED_FORMATS]\nif not so['formats']:\n    so['formats'] = ['markdown']","typeGuard":"def formats_valid(formats: list[str]) -> bool:\n    return all(f in ('markdown', 'html') for f in formats)","tryCatchPattern":"try:\n    tool.run(url, params=params)\nexcept ValueError as e:\n    if 'formats' in str(e):\n        params['scrape_options']['formats'] = ['markdown']\n        tool.run(url, params=params)\n    else:\n        raise","preventionTips":["Do not copy Firecrawl scrape_options into Hyperbrowser tools; the whitelists differ.","Filter formats against ('markdown','html') before invoking the tool."],"tags":["hyperbrowser","validation","scrape-options","whitelist"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}