apache/beam · error · ValueError
Unknown language for mapping transform
Error message
Unknown language for mapping transform: {language}. Supported languages are "javascript" and "python." What it means
`_as_callable` supports only language values 'javascript', 'python', 'generic', or unset (None). Any other `language` value in the transform config reaches this ValueError listing the supported languages.
Solutions
- Set language to exactly 'javascript' or 'python' (or omit it entirely for the default Python behavior).
- Fix casing and spelling: 'js' and 'JavaScript' are not accepted.
- If you need another language, implement the UDF in Python or JavaScript instead, or extend the transform.
Example fix
# before config: language: js # after config: language: javascript
Defensive patterns
Strategy: validation
Validate before calling
assert language in (None, 'python', 'generic', 'javascript'), f'unsupported language {language!r}' Type guard
def is_supported_language(lang) -> bool:
return lang in (None, 'python', 'generic', 'javascript') Try / catch
try:
run_pipeline(yaml_spec)
except ValueError as e:
if 'Unknown language for mapping transform' in str(e):
yaml_spec['config']['language'] = normalize_language(yaml_spec['config']['language'])
run_pipeline(yaml_spec)
else:
raise Prevention
- Use only 'python' or 'javascript', lowercase, no abbreviations
- Omit `language` when using Python (the default)
- Keep a whitelist in any tooling that generates these configs
When it happens
Trigger: Setting `language: js`, `language: java`, `language: Python` (case-sensitive — 'Python' with a capital P also fails? no: it compares exact strings, so 'Python' fails), or any typo'd language name in MapToFields/other mapping-transform config.
Common situations: Typos ('java' vs 'javascript', 'js' abbreviation), wrong casing ('Python'), or assuming other UDF languages (Go, SQL, Java) are supported in YAML mapping transforms.
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
- Ambiguous expression type (perhaps missing quoting?)
- CombineFn spec missing type
- cross_product must be specified true or false when…
- Missing combine parameter in Combine config.
- Unknown CombineFn
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/eb0eeed6a944b83a.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/yaml/yaml_mapping.py:413
# Extract original type from upstream pcoll when doing simple mappings
original_type = input_schema.get(expr.get('expression'), None)
if expr in original_fields:
language = "python"
# TODO(yaml): support an imports parameter
# TODO(yaml): support a requirements parameter (possibly at a higher level)
if not isinstance(expr, dict):
raise ValueError(
f"Ambiguous expression type (perhaps missing quoting?): {expr}")
explicit_type = expr.pop('output_type', None)
_check_mapping_arguments(transform_name, **expr)
if language == "javascript":
func = _expand_javascript_mapping_func(original_fields, **expr)
elif language in ("python", "generic", None):
func = _expand_python_mapping_func(original_fields, **expr)
else:
raise ValueError(
f'Unknown language for mapping transform: {language}. '
'Supported languages are "javascript" and "python."')
if explicit_type:
if isinstance(explicit_type, str):
explicit_type = {'type': explicit_type}
beam_type = json_utils.json_type_to_beam_type(explicit_type)
validator = _validator(beam_type)
@beam.typehints.with_output_types(schemas.typing_from_runner_api(beam_type))
def checking_func(row):
result = func(row)
if not validator(result):
raise TypeError(f'{result} violates schema {explicit_type}')
return result
return checking_func
View on GitHub (pinned to 12126d8942)