{"record":{"id":"79d7c9e2f677438a","repo":"apache/beam","slug":"transform-name-must-specify-either-expression-callable-or","errorCode":null,"errorMessage":"{transform_name} must specify either \"expression\", \"callable\", or both \"path\" and \"name\"","messagePattern":"(.+?) must specify either \"expression\", \"callable\", or both \"path\" and \"name\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_mapping.py","lineNumber":167,"sourceCode":"    ]\n  except (TypeError, ValueError):\n    input_fields = []\n\n  if base_type == 'MapToFields':\n    for field, value in list(config.get('fields', {}).items()):\n      validate_generic_expression(value, input_fields, True, field)\n\n  elif base_type in _str_expression_fields:\n    param = _str_expression_fields[base_type]\n    validate_generic_expression(\n        config.get(param), input_fields, base_type == 'Filter', param)\n\n\ndef _check_mapping_arguments(\n    transform_name, expression=None, callable=None, name=None, path=None):\n  # Argument checking\n  if not expression and not callable and not path and not name:\n    raise ValueError(\n        f'{transform_name} must specify either \"expression\", \"callable\", '\n        f'or both \"path\" and \"name\"')\n  if expression and callable:\n    raise ValueError(\n        f'{transform_name} cannot specify both \"expression\" and \"callable\"')\n  if (expression or callable) and (path or name):\n    raise ValueError(\n        f'{transform_name} cannot specify \"expression\" or \"callable\" with '\n        f'\"path\" or \"name\"')\n  if path and not name:\n    raise ValueError(f'{transform_name} cannot specify \"path\" without \"name\"')\n  if name and not path:\n    raise ValueError(f'{transform_name} cannot specify \"name\" without \"path\"')\n\n\n_THREAD_LOCAL_JS_CACHE = threading.local()\n\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_mapping.py#L149-L185","documentation":"_check_mapping_arguments validates the options of a mapping-style transform (e.g. MapToFields). This ValueError fires when none of the recognized options — expression, callable, path+name — are provided, so there is no way to construct the mapping function.","triggerScenarios":"Calling a mapping transform (via _as_callable) with an empty or all-empty configuration: no expression, no callable, no path and no name.","commonSituations":"YAML spec with an empty configuration block; copying a transform template and forgetting to fill in the expression; misspelling the option names so all appear unset.","solutions":["Add an `expression` (e.g. \"col + 1\") to the transform configuration.","Or provide a `callable` name or inline callable spec.","Or provide both `path` and `name` to load an external callable.","Check spelling of configuration keys (expression/callable/path/name)."],"exampleFix":"# before\n- type: MapToFields\n  config: {}\n# after\n- type: MapToFields\n  config:\n    language: python\n    expression: \"col * 2\"","handlingStrategy":"validation","validationCode":"assert any([expression, callable, path and name]), 'one of expression/callable/path+name required'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fill every copied config template before running","Validate option keys against the transform schema","Start from a working example pipeline"],"tags":["yaml","beam-yaml","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}