apache/beam · error · ValueError

Invalid value " " for "type". It must be a dict or a str.

Error message

Invalid value "{type}" for "type". It must be a dict or a str.

What it means

Thrown by _validate_type in apache_beam/yaml/yaml_join.py when the join 'type' parameter is neither a dict (outer-join specification) nor a str (inner/outer/left/right). Any other type (list, int, None, etc.) is rejected.

Solutions

  1. Set type to one of the strings 'inner', 'outer', 'left', 'right'.
  2. Or use a dict of the form {'outer': [list of input tags]} for outer joins.
  3. Quote string values in YAML so they are not misparsed.

Example fix

// before
type: [inner]
// after
type: inner
Defensive patterns

Strategy: validation

Validate before calling

if not (isinstance(t, str) or isinstance(t, dict)):
    raise TypeError("Join 'type' must be 'inner'|'outer'|'left'|'right' or {'outer': [...]}")

Type guard

def is_valid_join_type(t):
    return (isinstance(t, str) and t in ('inner', 'outer', 'left', 'right')) or isinstance(t, dict)

Prevention

When it happens

Trigger: Setting type: to a list, number, boolean, or null in the Join transform config; programmatically passing a non-str non-dict object as the type argument.

Common situations: YAML typos like type: [inner]; quoting errors making the value an array; passing Python None when the key is required.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/yaml/yaml_join.py:39

from typing import Union

import apache_beam as beam
from apache_beam.yaml import yaml_provider


def _validate_input(pcolls):
  error_prefix = f'Invalid input {pcolls} specified.'
  if not isinstance(pcolls, dict):
    raise ValueError(f'{error_prefix} It must be a dict.')
  if len(pcolls) < 2:
    raise ValueError(
        f'{error_prefix} There should be at least 2 inputs to join.')


def _validate_type(type, pcolls):
  error_prefix = f'Invalid value "{type}" for "type".'
  if not isinstance(type, dict) and not isinstance(type, str):
    raise ValueError(f'{error_prefix} It must be a dict or a str.')
  if isinstance(type, dict):
    error = ValueError(
        f'{error_prefix} When specifying a dict for type, '
        f'it must follow this format: '
        f'{{"outer": [list of inputs to outer join]}}. '
        f'Example: {{"outer": ["input1", "input2"]}}')
    if (len(type) != 1 or next(iter(type)) != 'outer' or
        not isinstance(type['outer'], list)):
      raise error
    for input in type['outer']:
      if input not in list(pcolls.keys()):
        raise ValueError(
            f'{error_prefix} An invalid input "{input}" was specified.')
  if isinstance(type, str) and type not in ('inner', 'outer', 'left', 'right'):
    raise ValueError(
        f'{error_prefix} When specifying the value for type as a str, '
        f'it must be one of the following: "inner", "outer", "left", "right"')

View on GitHub (pinned to 12126d8942)