apache/beam · error · ValueError

f'Unknown window type

Error message

f'Unknown window type {window_type}'

What it means

Raised by YamlProviders.WindowInto when the window 'type' parameter is not one of the supported window types (fixed, sliding, sessions). The YAML WindowInto transform dispatches on window_type and throws for anything else.

Solutions

  1. Use one of the supported types: 'fixed', 'sliding', or 'sessions'.
  2. Fix casing/typos, e.g. 'session' -> 'sessions'.
  3. If you need another window type, use the Python WindowInto transform directly instead of the YAML transform.

Example fix

# before
- type: AssignWindows
  config:
    type: session
    gap: 30s
# after
- type: AssignWindows
  config:
    type: sessions
    gap: 30s
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {'fixed', 'sliding', 'sessions'}
def validate_window_type(t):
    if t not in SUPPORTED:
        raise ValueError(f'window type {t!r} not in {sorted(SUPPORTED)}')

Type guard

def is_supported_window_type(t):
    return isinstance(t, str) and t in {'fixed', 'sliding', 'sessions'}

Try / catch

try:
    transform = YamlProviders.WindowInto(spec)
except ValueError as e:
    if str(e).startswith('Unknown window type'):
        logging.error('Unsupported window type; use fixed/sliding/sessions')
        raise
    raise

Prevention

When it happens

Trigger: Specifying type: global, type: interval, or any misspelled type (e.g. 'session' singular, 'Fixed') in the YAML WindowInto transform config.

Common situations: YAML pipeline authors copy window types from other frameworks, misspell 'sessions', or assume unsupported types like calendar or global windows are available (triggering/advanced windows are TODO in this provider).

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/yaml/yaml_provider.py:1166

      if window_type == 'global':
        window_fn = window.GlobalWindows()
      elif window_type == 'fixed':
        window_fn = window.FixedWindows(
            YamlProviders.WindowInto._parse_duration(spec.pop('size'), 'size'),
            YamlProviders.WindowInto._parse_duration(
                spec.pop('offset', 0), 'offset'))
      elif window_type == 'sliding':
        window_fn = window.SlidingWindows(
            YamlProviders.WindowInto._parse_duration(spec.pop('size'), 'size'),
            YamlProviders.WindowInto._parse_duration(
                spec.pop('period'), 'period'),
            YamlProviders.WindowInto._parse_duration(
                spec.pop('offset', 0), 'offset'))
      elif window_type == 'sessions':
        window_fn = window.Sessions(
            YamlProviders.WindowInto._parse_duration(spec.pop('gap'), 'gap'))
      else:
        raise ValueError(f'Unknown window type {window_type}')
      if spec:
        raise ValueError(f'Unknown parameters {spec.keys()}')
      # TODO: Triggering, etc.
      return beam.WindowInto(window_fn)

  @staticmethod
  @beam.ptransform_fn
  @maybe_with_exception_handling_transform_fn
  def log_for_testing(
      pcoll, *, level: Optional[str] = 'INFO', prefix: Optional[str] = ''):
    """Logs each element of its input PCollection.

    The output of this transform is a copy of its input for ease of use in
    chain-style pipelines.

    Args:
      level: one of ERROR, INFO, or DEBUG, mapped to a corresponding
        language-specific logging level

View on GitHub (pinned to 12126d8942)