{"record":{"id":"2f8ba64c3825d291","repo":"apache/beam","slug":"must-specify-one-of-callable-or-path-and-name-for-typ","errorCode":null,"errorMessage":"Must specify one of 'callable' or 'path' and 'name' for {typ} function.","messagePattern":"Must specify one of 'callable' or 'path' and 'name' for (.+?) function\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_ml.py","lineNumber":100,"sourceCode":"        postprocess, 'postprocess') or self.default_postprocess_fn()\n\n  def inference_output_type(self):\n    return Any\n\n  @staticmethod\n  def parse_processing_transform(processing_transform, typ):\n    def _parse_config(callable=None, path=None, name=None):\n      if callable and (path or name):\n        raise ValueError(\n            f\"Cannot specify 'callable' with 'path' and 'name' for {typ} \"\n            f\"function.\")\n      if path and name:\n        return python_callable.PythonCallableWithSource.load_from_script(\n            FileSystems.open(path).read().decode(), name)\n      elif callable:\n        return python_callable.PythonCallableWithSource(callable)\n      else:\n        raise ValueError(\n            f\"Must specify one of 'callable' or 'path' and 'name' for {typ} \"\n            f\"function.\")\n\n    if processing_transform:\n      if isinstance(processing_transform, dict):\n        return _parse_config(**processing_transform)\n      else:\n        raise ValueError(\"Invalid model_handler specification.\")\n\n  def underlying_handler(self):\n    return self._handler\n\n  @staticmethod\n  def default_preprocess_fn():\n    raise ValueError(\n        'Model Handler does not implement a default preprocess '\n        'method. Please define a preprocessing method using the '\n        '\\'preprocess\\' tag. This is required in most cases because '","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_ml.py#L82-L118","documentation":"`_parse_config` in yaml_ml.py:100 requires one of two ways to identify the processing function: an inline `callable`, or both a `path` (script file) and `name` (function in that script). If neither form is fully provided, ValueError is raised.","triggerScenarios":"Passing an empty dict or a dict missing keys, e.g. {path: preprocess.py} without `name`, or {name: my_fn} without `path`, or no preprocess config at all where one is required.","commonSituations":"Forgetting the `name` of the function inside the referenced script; specifying only path expecting the whole script to be used; empty `preprocess:` key in YAML.","solutions":["Provide both `path` and `name` when loading from a script: {path: preprocess.py, name: my_fn}.","Or provide an inline `callable` instead of path/name.","Verify the YAML preprocess block is not empty and all required keys are present."],"exampleFix":"# before\npreprocess: {path: preprocess.py}\n# after\npreprocess: {path: preprocess.py, name: my_preprocess_fn}","handlingStrategy":"validation","validationCode":"cfg = processing_transform if isinstance(processing_transform, dict) else {}\nok = ('callable' in cfg) or ('path' in cfg and 'name' in cfg)\nassert ok, 'must provide callable, or both path and name'","typeGuard":"def has_complete_fn_config(cfg):\n    return 'callable' in cfg or ('path' in cfg and 'name' in cfg)","tryCatchPattern":"try:\n    fn = parse_processing_transform(spec, typ)\nexcept ValueError as e:\n    raise YamlConfigError('preprocess needs callable or path+name') from e","preventionTips":["Always specify function `name` alongside `path` for script-based configs.","Never leave a preprocess block empty; omit it only if the handler has a default.","Templatize preprocess configs to keep required keys present."],"tags":["python","apache-beam","yaml-ml","missing-argument"],"backgroundTag":"missing-required-config-field","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"}