{"record":{"id":"71b610c2ef59d731","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"no-html-body-content-found-in-the-local-source","errorCode":null,"errorMessage":"No HTML body content found in the local source.","messagePattern":"No HTML body content found in the local source\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/nodes/fetch_node.py","lineNumber":241,"sourceCode":"    def handle_local_source(self, state, source):\n        \"\"\"\n        Handles the local source by fetching HTML content, optionally converting it to Markdown,\n        and updating the state.\n\n        Parameters:\n        state (dict): The current state of the graph.\n        source (str): The HTML content from the local source.\n\n        Returns:\n        dict: The updated state with the processed content.\n\n        Raises:\n        ValueError: If the source is empty or contains only whitespace.\n        \"\"\"\n\n        self.logger.info(f\"--- (Fetching HTML from: {source}) ---\")\n        if not source.strip():\n            raise ValueError(\"No HTML body content found in the local source.\")\n\n        parsed_content = source\n\n        if (\n            (\n                isinstance(self.llm_model, ChatOpenAI)\n                or isinstance(self.llm_model, AzureChatOpenAI)\n            )\n            and not self.script_creator\n            or self.force\n            and not self.script_creator\n        ):\n            parsed_content = convert_to_md(source)\n        else:\n            parsed_content = source\n\n        compressed_document = [\n            Document(page_content=parsed_content, metadata={\"source\": \"local_dir\"})","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/nodes/fetch_node.py#L223-L259","documentation":"handle_local_source treats the 'source' as raw HTML content when input resolves to a local string; if source.strip() is empty there is no document to process and this ValueError is raised.","triggerScenarios":"Passing source='' or a whitespace-only string with the local input path; upstream node producing empty HTML into state['source']; reading a file that is empty and passing its contents.","commonSituations":"Chaining graphs where the previous step emitted empty content; placeholders like source=' ' in configs; failed file reads that return '' silently.","solutions":["Check that the source string contains actual HTML before running the graph","Fix the upstream step that produced empty content","Add a guard/log for empty documents in your orchestration code"],"exampleFix":"# before\ngraph_config = {'source': ''}\n# after\nhtml = Path('page.html').read_text()\nassert html.strip(), 'empty html'\ngraph_config = {'source': html}","handlingStrategy":"validation","validationCode":"if not isinstance(source, str) or not source.strip():\n    raise ValueError('source HTML is empty; check upstream content')","typeGuard":"def has_html_content(s) -> bool:\n    return isinstance(s, str) and bool(s.strip())","tryCatchPattern":"try:\n    node.execute(state)\nexcept ValueError as e:\n    if 'No HTML body content found in the local source' in str(e):\n        # fetch content again or skip\n        pass\n    else:\n        raise","preventionTips":["Assert non-empty source strings before running graphs","Guard against empty upstream outputs when chaining graphs"],"tags":["scrapegraphai","fetch-node","local-source","empty-input"],"backgroundTag":"empty-required-input","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}