ScrapeGraphAI/Scrapegraph-ai · error · ValueError

No parsed documents found in state

Error message

No parsed documents found in state

What it means

BatchGenerateAnswerNode.execute requires the 'parsed_docs' entry in the graph state to be non-empty before it can build batch requests. If state has no parsed_docs or it is an empty list, this ValueError is raised immediately.

Source

Thrown at scrapegraphai/nodes/batch_generate_answer_node.py:168

        Args:
            state (dict): Must contain:
                - user_prompt: The user's question.
                - parsed_docs: List of parsed document contents.
                - urls: List of source URLs (for result mapping).

        Returns:
            dict: Updated state with 'results' key containing
                  a list of answers (one per document).
        """
        self.logger.info(f"--- Executing {self.node_name} Node ---")

        user_prompt = state.get("user_prompt", "")
        parsed_docs = state.get("parsed_docs", [])
        urls = state.get("urls", [])

        if not parsed_docs:
            raise ValueError("No parsed documents found in state")

        model_name = self._get_model_name()
        format_instructions = self._get_format_instructions()

        # Build batch requests with doc_id → URL mapping
        batch_requests = []
        doc_id_to_url = {}

        for i, doc in enumerate(parsed_docs):
            custom_id = f"doc_{i:04d}"
            doc_id_to_url[custom_id] = urls[i] if i < len(urls) else f"doc_{i}"

            # Handle chunked documents — use first chunk for batch
            content = doc[0] if isinstance(doc, list) and len(doc) == 1 else str(doc)

            prompt_text = self._build_prompt_text(
                user_prompt, content, format_instructions
            )

View on GitHub (pinned to 532dfffbf6)

Solutions

  1. Verify the upstream fetch/parse nodes ran and populated state['parsed_docs']
  2. Debug the preceding node's output (log len(state['parsed_docs']) before the batch node)
  3. Seed parsed_docs with Document objects when unit-testing the node

Example fix

# before
state = {'user_prompt': 'summarize'}
node.execute(state)  # raises
# after
from langchain_core.documents import Document
state = {'user_prompt': 'summarize', 'parsed_docs': [Document(page_content='...')]}
node.execute(state)
Defensive patterns

Strategy: validation

Validate before calling

if not state.get('parsed_docs'):
    raise RuntimeError('upstream parse produced no docs; skipping batch step')

Try / catch

try:
    out = node.execute(state)
except ValueError as e:
    if 'No parsed documents' in str(e):
        # re-run fetch/parse or log and skip
        pass
    else:
        raise

Prevention

When it happens

Trigger: Running a batch graph where the parsing step produced no documents; skipping the parse step in the pipeline; passing an empty 'parsed_docs' list in a manually constructed state during tests.

Common situations: Upstream ParseNode/FetchNode failed silently or the source URL returned nothing; testing the node in isolation without seeding parsed_docs; wrong graph wiring that skips the parsing node.

Related errors


AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28). Data as JSON: /api/errors/878b0dd75e4bdd57. Report an issue: GitHub.