ValueError
haystack.pipelines.base.ValueError
Stack trace
Traceback (most recent call last):
File "app.py", line 42, in <module>
result = pipeline.run("What is AI?") # Missing required input key
File "/usr/local/lib/python3.9/site-packages/haystack/pipelines/base.py", line 123, in run
raise ValueError(f"Pipeline run missing input for key: {missing_key}")
ValueError: Pipeline run missing input for key: 'query' Why it happens
Haystack pipelines require specific input keys to be passed to the run() method matching the pipeline's node input expectations. If the input dictionary lacks these keys or if inputs are passed as positional arguments instead of keyword arguments, the pipeline raises this error.
Detection
Check that the dictionary passed to pipeline.run() includes all required input keys exactly as defined in the pipeline nodes before execution to avoid runtime failures.
Causes & fixes
Calling pipeline.run() with positional arguments instead of keyword arguments for required inputs
Always pass inputs as keyword arguments matching the pipeline's expected input keys, e.g., pipeline.run(query='text') instead of pipeline.run('text')
Missing required input key in the dictionary passed to pipeline.run()
Ensure all required input keys are included in the input dictionary passed to pipeline.run(), matching the pipeline node input names exactly
Mismatch between pipeline node input names and keys used in run() call
Verify the pipeline node input names via pipeline.graph or documentation and use those exact keys in the run() input dictionary
Code: broken vs fixed
from haystack.pipelines import Pipeline
pipeline = Pipeline()
result = pipeline.run("What is AI?") # Missing input key, causes ValueError
print(result) import os
from haystack.pipelines import Pipeline
pipeline = Pipeline()
result = pipeline.run(query="What is AI?") # Fixed: pass input as keyword argument
print(result) # Shows pipeline output Workaround
Wrap pipeline.run() in try/except ValueError, catch missing input errors, and log the missing keys to dynamically adjust or provide fallback inputs.
Prevention
Design pipeline input schemas clearly and validate input dictionaries before calling run(), using static typing or input validation utilities to ensure all required keys are present.