ScrapeGraphAI/Scrapegraph-ai · error · ValueError
Invalid input type: {input_type}
Error message
Invalid input type: {input_type} What it means
FetchNode.execute dispatches on input_type: registered handlers, then 'local_dir', then 'url'; anything else falls through to this ValueError. input_type is typically derived from the source (a URL vs a path), so an unrecognized source format produces this error.
Source
Thrown at scrapegraphai/nodes/fetch_node.py:126
"xml_dir": self.handle_directory,
"csv_dir": self.handle_directory,
"pdf_dir": self.handle_directory,
"md_dir": self.handle_directory,
"pdf": self.handle_file,
"csv": self.handle_file,
"json": self.handle_file,
"xml": self.handle_file,
"md": self.handle_file,
}
if input_type in handlers:
return handlers[input_type](state, input_type, source)
elif input_type == "local_dir":
return self.handle_local_source(state, source)
elif input_type == "url":
return self.handle_web_source(state, source)
else:
raise ValueError(f"Invalid input type: {input_type}")
def handle_directory(self, state, input_type, source):
"""
Handles the directory by compressing the source document and updating the state.
Parameters:
state (dict): The current state of the graph.
input_type (str): The type of input being processed.
source (str): The source document to be compressed.
Returns:
dict: The updated state with the compressed document.
"""
compressed_document = [source]
state.update({self.output[0]: compressed_document})
return state
View on GitHub (pinned to 532dfffbf6)
Solutions
- Check what input_type is resolved to (log it) and fix the source to a supported type: 'url', 'local_dir', or a recognized file/directory path
- Ensure the graph config's 'source' points to a valid http(s) URL or local path
- If using a custom source type, register an appropriate handler or preprocess the source into HTML first
Example fix
# before
graph_config = {'source': 'ftp://example.com/doc'}
# after
graph_config = {'source': 'https://example.com/doc'} Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlparse
SUPPORTED = ('http', 'https')
def source_ok(src: str) -> bool:
u = urlparse(src)
return u.scheme in SUPPORTED or (not u.scheme and Path(src).exists()) Type guard
def is_fetchable_source(s: str) -> bool:
return s.startswith(('http://','https://')) or os.path.exists(s) Try / catch
try:
node.execute(state)
except ValueError as e:
if 'Invalid input type' in str(e):
raise ValueError(f'unsupported source: {state.get("source")!r}') from e
raise Prevention
- Normalize sources to http(s) URLs or verified local paths before graph run
- Reject schemes like ftp:// in your orchestration layer
When it happens
Trigger: Passing a source string that is neither a URL, existing local path, directory, nor a registered file type — e.g. a malformed scheme like 'ftp://...' or a typo'd input key. Also when 'input_type' in state/config is set to an unsupported value.
Common situations: Wrong 'input' source key in the graph config; passing s3:// or other unsupported schemes; state accidentally containing an input_type value set by a custom upstream node.
Related errors
- 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 local source.
- No HTML body content found in the response.
- The browserbase module is not installed.
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/6664324bc58dee9a.
Report an issue: GitHub.