Skip to content

fix: Handle multi-output fan-out in _build_output_mapping_from_edges (langflow-stepflow) #12308

@coderabbitai

Description

@coderabbitai

Summary

In src/langflow-stepflow/src/langflow_stepflow/translation/translator.py, the _build_output_mapping_from_edges method uses a first-edge-wins strategy that collapses all outgoing edges from a single source node into a single source_id -> output_name entry. This is lossy when a node fans out to multiple targets using different outputs — at least one downstream path will receive the wrong output.

Steps to reproduce / Follow-up work

  1. Identify (or author) a Langflow flow where a single component exposes multiple outputs and connects each to a different downstream node (e.g., a component with both a message and a data output, each wired to a separate target).
  2. Verify that the current first-edge-wins mapping causes the wrong output to be selected for at least one consumer.
  3. Change the mapping to be edge-scoped (e.g., keyed by (source_id, target_id) or by edge id) so each edge retains its selected output name.
  4. Update NodeProcessor (and any other callers of _build_output_mapping_from_edges) to look up the output using the edge-scoped key.
  5. Add a regression test using the flow from step 1.

Context

Flagged during review of PR #12015. The first-edge-wins approach works for all existing tested flows, but is architecturally unsound for general multi-output fan-out scenarios.

Backlinks: PR #12015, comment #12015 (comment)

Requested by @bjchambers.

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