{"record":{"id":"0a34793b5261b102","repo":"apache/beam","slug":"unknown-combinefn-fn-spec","errorCode":null,"errorMessage":"Unknown CombineFn: {fn_spec}","messagePattern":"Unknown CombineFn: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_combine.py","lineNumber":133,"sourceCode":"    all_fields = list(input_types.keys())\n    unknown_keys = set(self._group_by) - set(all_fields)\n    if unknown_keys:\n      raise ValueError(f'Unknown grouping columns: {list(unknown_keys)}')\n\n    def create_combine_fn(fn_spec):\n      if 'type' not in fn_spec:\n        raise ValueError(f'CombineFn spec missing type: {fn_spec}')\n      elif fn_spec['type'] in BUILTIN_COMBINE_FNS:\n        return BUILTIN_COMBINE_FNS[fn_spec['type']]\n      elif self._language == 'python':\n        # TODO(yaml): Support output_type here as well.\n        fn = python_callable.PythonCallableWithSource.load_from_source(\n            fn_spec['type'])\n        if 'config' in fn_spec:\n          fn = fn(**fn_spec['config'])\n        return fn\n      else:\n        raise TypeError('Unknown CombineFn: {fn_spec}')\n\n    def extract_return_type(expr):\n      if isinstance(expr, str) and expr in input_types:\n        return input_types[expr]\n      expr_hints = get_type_hints(expr)\n      if (expr_hints and expr_hints.has_simple_output_type() and\n          expr_hints.simple_output_type(None) != typehints.Any):\n        return expr_hints.simple_output_type(None)\n      elif callable(expr):\n        return trivial_inference.infer_return_type(expr, [pcoll.element_type])\n      else:\n        return Any\n\n    # TODO(yaml): Support error handling.\n    transform = beam.GroupBy(*self._group_by)\n    output_types = [(k, input_types[k]) for k in self._group_by]\n\n    for output, agg in self._combine.items():","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_combine.py#L115-L151","documentation":"While building a CombineFn for a YAML group_by aggregation, create_combine_fn found a spec whose 'type' names neither a builtin CombineFn nor a loadable Python callable in the configured language; the full spec is shown so the unsupported name is identifiable.","triggerScenarios":"fn: {type: sumAll} with no such builtin and language not python, or a Python source string that fails to load as a callable; also when language is java/sql but a Python-only spec is given.","commonSituations":"Typos in builtin names ('Sum' vs 'sum'); using a custom Python CombineFn while the transform is configured with language: java; forgetting to include the callable source inline.","solutions":["Use one of the documented builtin combine fn names (check BUILTIN_COMBINE_FNS).","For custom logic, set language: python and provide the full callable source as the type string.","Fix the casing/spelling of the fn type."],"exampleFix":"// before\ncombine:\n  total: {fn: {type: Sum}, value: amount}\n// after\ncombine:\n  total: {fn: {type: sum}, value: amount}","handlingStrategy":"validation","validationCode":"from apache_beam.yaml.yaml_combine import BUILTIN_COMBINE_FNS\ndef check_fn_type(fn_spec: dict, language: str):\n    t = fn_spec.get('type')\n    if t in BUILTIN_COMBINE_FNS:\n        return\n    if language != 'python':\n        raise SystemExit(f'Unknown CombineFn {t!r}; use a builtin or set language: python with callable source')","typeGuard":"def is_known_combine_fn(fn_spec: dict, language: str) -> bool:\n    t = fn_spec.get('type')\n    return isinstance(t, str) and (t in BUILTIN_COMBINE_FNS or language == 'python')","tryCatchPattern":"try:\n    expand(pcoll)\nexcept TypeError as e:\n    if 'Unknown CombineFn' in str(e):\n        raise SystemExit(f'Use one of {sorted(BUILTIN_COMBINE_FNS)} or provide a Python callable source') from e\n    raise","preventionTips":["Prefer builtin combine fn names","Set language: python when using custom callables","Spell names exactly as documented (lowercase builtins)"],"tags":["yaml","config","beam-yaml"],"backgroundTag":"invalid-enum-value","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"}