Description
When users run an output/choice node before running its upstream provider node, the node may receive text data (like an LLM-generated prompt string) instead of the expected file path. This text is then incorrectly treated as a filepath, leading to confusing errors.
Steps to Reproduce
- Build a graph with:
LLM → Music Provider → Audio Output
- Run the LLM node to generate a music prompt
- Without running the Music Provider node, click "Run" on the Audio Output node
- The output node receives the LLM's text prompt instead of an audio file path
Expected Behavior
Either:
- The UI should prevent running a node before its dependencies have produced valid output
- Or the node should provide a clear, actionable error message explaining the execution order
Actual Behavior
The text prompt is passed to the audio component, which may:
- Try to interpret a long sentence as a file path
- Show a cryptic error about missing files
- Fail silently or show misleading errors
Current Workaround
Add guards in the postprocess function to detect when text is incorrectly passed as audio data:
def audio_postprocess(audio_out, *rest):
"""
Guard against TEXT being passed as 'audio' (common when downstream node is run too early)
"""
if isinstance(audio_out, str):
s = audio_out.strip()
# Heuristic: long, space-filled, not a local path, not a gradio file URL
looks_like_prompt_text = (
len(s) > 120
and (" " in s)
and not s.startswith("/")
and "gradio_api/file=" not in s
)
if looks_like_prompt_text:
raise RuntimeError(
"Audio node received TEXT instead of an audio file.\n"
"This usually happens when you run the audio output/choice node before running a provider.\n"
"Run the selected music provider node first, then run the output node."
)
# If it's a string and looks like a path, ensure it exists
if s.startswith("/") and not os.path.exists(s):
raise RuntimeError(
f"Audio path does not exist yet: {s}\n"
"Run the selected music provider node first, then run the output node."
)
# ... rest of postprocess logic
Suggested Fix
- UI-level fix: Disable the "Run" button on nodes whose upstream dependencies haven't been executed yet, or show a warning
- Framework-level fix: Add built-in type validation that detects mismatched data types (e.g., text where file is expected)
- Error messaging: Provide clearer error messages when execution order issues are detected
Reference
Description
When users run an output/choice node before running its upstream provider node, the node may receive text data (like an LLM-generated prompt string) instead of the expected file path. This text is then incorrectly treated as a filepath, leading to confusing errors.
Steps to Reproduce
LLM → Music Provider → Audio OutputExpected Behavior
Either:
Actual Behavior
The text prompt is passed to the audio component, which may:
Current Workaround
Add guards in the
postprocessfunction to detect when text is incorrectly passed as audio data:Suggested Fix
Reference