apache/beam · error · ValueError

Node ID cannot be empty

Error message

Node ID cannot be empty

What it means

NodeData.__post_init__ (a dataclass validator) raises this ValueError when a node parsed from the SidePanel YAML graph definition has an empty id. IDs are required keys used to link nodes and edges in the interactive graph, so an empty one is rejected immediately at object construction.

Source

Thrown at sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/apache_beam_jupyterlab_sidepanel/yaml_parse_utils.py:36

import yaml

import apache_beam as beam
from apache_beam.yaml.main import build_pipeline_components_from_yaml

# ======================== Type Definitions ========================


@dataclass
class NodeData:
  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]]

View on GitHub (pinned to 12126d8942)

Solutions

  1. Give every node in the YAML a non-empty unique id field.
  2. Validate the YAML before loading (assert each node has a truthy id).
  3. Fix programmatic YAML generation so id is always populated.
  4. Add a schema check step that fails early with the offending node name/index.

Example fix

// before (yaml)
nodes:
  - label: Inspect
    type: transform
// after
nodes:
  - id: node-1
    label: Inspect
    type: transform
Defensive patterns

Strategy: validation

Validate before calling

def validate_nodes(nodes):
    for i, n in enumerate(nodes):
        assert n.get('id'), f'node[{i}] has empty id: {n}'

Type guard

def node_is_valid(n: dict) -> bool:
    return bool(isinstance(n, dict) and n.get('id'))

Try / catch

try:
    node = NodeData(id=node_dict.get('id', ''), label=node_dict.get('label', ''), type=node_dict.get('type', ''))
except ValueError as e:
    raise YamlSchemaError(f'Bad node in SidePanel YAML: {node_dict}') from e

Prevention

When it happens

Trigger: Defining a node in the SidePanel YAML with a missing or empty 'id' field (id: '' or the key omitted), then parsing it via yaml_parse_utils, which constructs NodeData(id=...) and triggers __post_init__.

Common situations: Hand-editing the notebook/SidePanel YAML and deleting the id line; generating YAML programmatically where id defaults to empty string; copy-pasting a node template and forgetting to fill in the id.

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/da11f886b5bfba82. Report an issue: GitHub.