apache/beam · error · ValueError

cannot specify "path" without "name

Error message

{transform_name} cannot specify "path" without "name"

What it means

External callables loaded from a file require both `path` (file location) and `name` (symbol name). This ValueError fires when `path` is specified but `name` is missing, so the callable cannot be resolved from the file.

Solutions

  1. Add the `name` key with the function name defined in the path file.
  2. Verify the named function actually exists in the file at `path`.
  3. Check for key typos (`function` vs `name`).
  4. Alternatively drop `path` and use an inline expression/callable if no file is needed.

Example fix

# before
config:
  path: ./myfuncs.py
# after
config:
  path: ./myfuncs.py
  name: my_udf
Defensive patterns

Strategy: validation

Validate before calling

if config.get('path') and not config.get('name'):
    raise ValueError('path requires name')

Prevention

When it happens

Trigger: Configuring a mapping transform with `path: ./funcs.py` but omitting `name`, via _as_callable.

Common situations: Assuming the file's single function is auto-discovered; truncating a config example that included both keys; key renamed or typo'd as `function` instead of `name`.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/yaml/yaml_mapping.py:178

        config.get(param), input_fields, base_type == 'Filter', param)


def _check_mapping_arguments(
    transform_name, expression=None, callable=None, name=None, path=None):
  # Argument checking
  if not expression and not callable and not path and not name:
    raise ValueError(
        f'{transform_name} must specify either "expression", "callable", '
        f'or both "path" and "name"')
  if expression and callable:
    raise ValueError(
        f'{transform_name} cannot specify both "expression" and "callable"')
  if (expression or callable) and (path or name):
    raise ValueError(
        f'{transform_name} cannot specify "expression" or "callable" with '
        f'"path" or "name"')
  if path and not name:
    raise ValueError(f'{transform_name} cannot specify "path" without "name"')
  if name and not path:
    raise ValueError(f'{transform_name} cannot specify "name" without "path"')


_THREAD_LOCAL_JS_CACHE = threading.local()


class _JsFunctionWrapper:
  def __init__(self, source_code, entrypoint_name):
    self.source_code = source_code
    self.entrypoint_name = entrypoint_name

  def _get_fn(self):
    cache = _THREAD_LOCAL_JS_CACHE
    if not hasattr(cache, 'functions'):
      cache.functions = {}

    cache_key = (self.source_code, self.entrypoint_name)

View on GitHub (pinned to 12126d8942)