ScrapeGraphAI/Scrapegraph-ai · error · ValueError
No HTML body content found in the local source.
Error message
No HTML body content found in the local source.
What it means
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.
Source
Thrown at scrapegraphai/nodes/fetch_node.py:241
def handle_local_source(self, state, source):
"""
Handles the local source by fetching HTML content, optionally converting it to Markdown,
and updating the state.
Parameters:
state (dict): The current state of the graph.
source (str): The HTML content from the local source.
Returns:
dict: The updated state with the processed content.
Raises:
ValueError: If the source is empty or contains only whitespace.
"""
self.logger.info(f"--- (Fetching HTML from: {source}) ---")
if not source.strip():
raise ValueError("No HTML body content found in the local source.")
parsed_content = source
if (
(
isinstance(self.llm_model, ChatOpenAI)
or isinstance(self.llm_model, AzureChatOpenAI)
)
and not self.script_creator
or self.force
and not self.script_creator
):
parsed_content = convert_to_md(source)
else:
parsed_content = source
compressed_document = [
Document(page_content=parsed_content, metadata={"source": "local_dir"})View on GitHub (pinned to 532dfffbf6)
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
Example fix
# before
graph_config = {'source': ''}
# after
html = Path('page.html').read_text()
assert html.strip(), 'empty html'
graph_config = {'source': html} Defensive patterns
Strategy: validation
Validate before calling
if not isinstance(source, str) or not source.strip():
raise ValueError('source HTML is empty; check upstream content') Type guard
def has_html_content(s) -> bool:
return isinstance(s, str) and bool(s.strip()) Try / catch
try:
node.execute(state)
except ValueError as e:
if 'No HTML body content found in the local source' in str(e):
# fetch content again or skip
pass
else:
raise Prevention
- Assert non-empty source strings before running graphs
- Guard against empty upstream outputs when chaining graphs
When it happens
Trigger: 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.
Common situations: Chaining graphs where the previous step emitted empty content; placeholders like source=' ' in configs; failed file reads that return '' silently.
Related errors
- No parsed documents found in state
- Invalid input type: {input_type}
- PDF parsing exceeded timeout of {self.timeout} seconds
- pandas is not installed. Please install it using `pip instal
- No HTML body content found in the response.
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/71b610c2ef59d731.
Report an issue: GitHub.