apache/beam · error · ValueError
cannot specify "expression" or "callable" with "path" or…
Error message
{transform_name} cannot specify "expression" or "callable" with "path" or "name" What it means
_check_mapping_arguments disallows combining inline definitions (expression or callable) with external loading options (path or name). This ValueError fires when any of expression/callable is set together with path or name, since a field must be defined either inline or externally, not both.
Solutions
- Delete the inline `expression`/`callable` and keep path+name for external loading.
- Or delete `path`/`name` and keep the inline definition.
- Keep each field's definition in exactly one style.
- Review copied YAML templates for leftover keys.
Example fix
# before config: expression: "x + 1" path: ./myfuncs.py name: double # after config: path: ./myfuncs.py name: double
Defensive patterns
Strategy: validation
Validate before calling
inline = bool(config.get('expression') or config.get('callable'))
external = bool(config.get('path') or config.get('name'))
assert not (inline and external), 'cannot mix inline and path/name definitions' Prevention
- Decide inline vs external loading up front per field
- Audit config templates for leftover keys
- Use a JSON/YAML schema validator on pipeline configs
When it happens
Trigger: Configuring a mapping transform where `expression` (or `callable`) coexists with `path` and/or `name` in the same configuration.
Common situations: Adding an import path for a helper while leaving a stale inline expression; template configs that already contain one style plus a newly pasted other style.
Related errors
- cannot specify both "expression" and "callable
- Ambiguous expression type (perhaps missing quoting?)
- Ambiguous expression type (perhaps missing quoting?)
- Can only use expressions on a schema'd input.
- CombineFn spec missing type
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/051dd95fd75d3e3e.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/yaml/yaml_mapping.py:174
elif base_type in _str_expression_fields:
param = _str_expression_fields[base_type]
validate_generic_expression(
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_CACHEView on GitHub (pinned to 12126d8942)