Skip to content

Execution order UX: running output node before provider treats text as filepath #47

@abidlabs

Description

@abidlabs

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

  1. Build a graph with: LLM → Music Provider → Audio Output
  2. Run the LLM node to generate a music prompt
  3. Without running the Music Provider node, click "Run" on the Audio Output node
  4. 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

  1. UI-level fix: Disable the "Run" button on nodes whose upstream dependencies haven't been executed yet, or show a warning
  2. Framework-level fix: Add built-in type validation that detects mismatched data types (e.g., text where file is expected)
  3. Error messaging: Provide clearer error messages when execution order issues are detected

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions