{"record":{"id":"051dd95fd75d3e3e","repo":"apache/beam","slug":"transform-name-cannot-specify-expression-or-callable-with","errorCode":null,"errorMessage":"{transform_name} cannot specify \"expression\" or \"callable\" with \"path\" or \"name\"","messagePattern":"(.+?) cannot specify \"expression\" or \"callable\" with \"path\" or \"name\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_mapping.py","lineNumber":174,"sourceCode":"\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\nclass _JsFunctionWrapper:\n  def __init__(self, source_code, entrypoint_name):\n    self.source_code = source_code\n    self.entrypoint_name = entrypoint_name\n\n  def _get_fn(self):\n    cache = _THREAD_LOCAL_JS_CACHE","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_mapping.py#L156-L192","documentation":"_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.","triggerScenarios":"Configuring a mapping transform where `expression` (or `callable`) coexists with `path` and/or `name` in the same configuration.","commonSituations":"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.","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."],"exampleFix":"# before\nconfig:\n  expression: \"x + 1\"\n  path: ./myfuncs.py\n  name: double\n# after\nconfig:\n  path: ./myfuncs.py\n  name: double","handlingStrategy":"validation","validationCode":"inline = bool(config.get('expression') or config.get('callable'))\nexternal = bool(config.get('path') or config.get('name'))\nassert not (inline and external), 'cannot mix inline and path/name definitions'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide inline vs external loading up front per field","Audit config templates for leftover keys","Use a JSON/YAML schema validator on pipeline configs"],"tags":["yaml","beam-yaml","conflicting-options"],"backgroundTag":"mutually-exclusive-options","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"}