apache/beam · error · ValueError
Edge source and target cannot be empty
Error message
Edge source and target cannot be empty
What it means
EdgeData.__post_init__ raises this ValueError when an edge in the SidePanel YAML graph has an empty source or target. Both endpoints are required to connect two nodes in the interactive pipeline graph, so edges lacking either are rejected at construction.
Source
Thrown at sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/apache_beam_jupyterlab_sidepanel/yaml_parse_utils.py:47
id: str
label: str
type: str = ""
def __post_init__(self):
# Ensure ID is not empty
if not self.id:
raise ValueError("Node ID cannot be empty")
@dataclass
class EdgeData:
source: str
target: str
label: str = ""
def __post_init__(self):
if not self.source or not self.target:
raise ValueError("Edge source and target cannot be empty")
class FlowGraph(TypedDict):
nodes: list[dict[str, Any]]
edges: list[dict[str, Any]]
# ======================== Main Function ========================
def parse_beam_yaml(yaml_str: str, isDryRunMode: bool = False) -> str:
"""
Parse Beam YAML and convert to flow graph data structure
Args:
yaml_str: Input YAML string
Returns:View on GitHub (pinned to 12126d8942)
Solutions
- Set non-empty source and target on every edge, matching existing node ids.
- Validate the YAML: for each edge check source and target exist in the node id set before parsing.
- Fix templates/generators that emit empty endpoint fields.
- Rename node ids consistently across nodes and edges to avoid dangling/empty references.
Example fix
// before (yaml)
edges:
- source: node-1
// after
edges:
- source: node-1
target: node-2 Defensive patterns
Strategy: validation
Validate before calling
def validate_edges(nodes, edges):
ids = {n['id'] for n in nodes}
for i, e in enumerate(edges):
assert e.get('source') and e.get('target'), f'edge[{i}] missing endpoint: {e}'
assert e['source'] in ids and e['target'] in ids, f'edge[{i}] references unknown node' Type guard
def edge_is_valid(e: dict) -> bool:
return bool(isinstance(e, dict) and e.get('source') and e.get('target')) Try / catch
try:
edge = EdgeData(source=edge_dict['source'], target=edge_dict['target'])
except ValueError as e:
raise YamlSchemaError(f'Bad edge in SidePanel YAML: {edge_dict}') from e Prevention
- Give every edge non-empty source and target matching existing node ids
- Run a pre-parse consistency check of nodes vs edges
- Rename node ids in edges whenever nodes are renamed
- Fix YAML templates so endpoint placeholders are always filled
When it happens
Trigger: Defining an edge in the YAML with missing/empty 'source' or 'target' keys, or referencing keys that parsed to empty strings, when yaml_parse_utils constructs EdgeData.
Common situations: Hand-edited YAML where the source/target line was deleted; templated YAML with unfilled placeholders ('' defaults); YAML with keys whose values are empty due to unexpanded variables; referencing a node id that was renamed so the field becomes empty.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Node ID cannot be empty
- Incompatible types: {weak_schema['type']} vs {strong_schema[
- Unknown output name "{tag}" from {by}
- HuggingFacePipelineModelHandler requires either 'task' or 'm
- Unexpected parameters in model_handler: {extra_params}
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/bb4006e94801a581.
Report an issue: GitHub.