{"record":{"id":"f7a251437fdc365a","repo":"apache/beam","slug":"unknown-ml-transform-type-r","errorCode":null,"errorMessage":"Unknown ML transform type: %r","messagePattern":"Unknown ML transform type: %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_ml.py","lineNumber":596,"sourceCode":"                  model_handler_provider._preprocess_fn_internal()).\n          with_postprocess_fn(\n              model_handler_provider._postprocess_fn_internal()),\n          inference_args=inference_args)\n      | beam.Map(\n          lambda row: beam.Row(\n              **{\n                  **row[0]._asdict(), str(inference_tag): row[1]\n              })).with_output_types(schema))\n\n\ndef _config_to_obj(spec):\n  if 'type' not in spec:\n    raise ValueError(f\"Missing type in ML transform spec {spec}\")\n  if 'config' not in spec:\n    raise ValueError(f\"Missing config in ML transform spec {spec}\")\n  constructor = _transform_constructors.get(spec['type'])\n  if constructor is None:\n    raise ValueError(\"Unknown ML transform type: %r\" % spec['type'])\n  return constructor(**spec['config'])\n\n\n@beam.ptransform.ptransform_fn\ndef ml_transform(\n    pcoll,\n    write_artifact_location: Optional[str] = None,\n    read_artifact_location: Optional[str] = None,\n    transforms: Optional[list[Any]] = None):\n  if MLTransform is None:\n    raise ValueError(\n        'No MLTransform found. Please install tensorflow-transform or '\n        'sentence-transformers to use this transform.')\n  options.YamlOptions.check_enabled(pcoll.pipeline, 'ML')\n  result_ml_transform = MLTransform(\n      write_artifact_location=write_artifact_location,\n      read_artifact_location=read_artifact_location,\n      transforms=[_config_to_obj(t) for t in transforms] if transforms else [])","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_ml.py#L578-L614","documentation":"After resolving the 'type' key in an ML transform spec, _config_to_obj found no registered provider under that name; it is a generic unknown-type guard for the provider registry used by YAML ML transforms.","triggerScenarios":"spec['type'] not in _transform_constructors, e.g. type: Inference instead of RunInference, wrong casing ('runinference'), or a transform added in a newer Beam version than installed.","commonSituations":"Typos in YAML transform type names; using aliases not supported by this Beam version; custom transforms not registered in _transform_constructors; docs from a different release.","solutions":["Use a supported type such as 'RunInference'","Check _transform_constructors keys for the exact accepted names","Upgrade apache_beam if the transform exists only in newer versions","Register custom constructors in _transform_constructors before use"],"exampleFix":"# before\ntype: MLInference\n# after\ntype: RunInference","handlingStrategy":"validation","validationCode":"from apache_beam.yaml.yaml_ml import _transform_constructors\ndef check_transform_type(typ):\n    if typ not in _transform_constructors:\n        raise ValueError(f'Unknown ML transform {typ!r}; known: {sorted(_transform_constructors)}')","typeGuard":"def is_known_transform_type(typ):\n    from apache_beam.yaml.yaml_ml import _transform_constructors\n    return typ in _transform_constructors","tryCatchPattern":"try:\n    t = _config_to_obj(spec)\nexcept ValueError as e:\n    if 'Unknown ML transform type' in str(e):\n        log_known_types(); correct_spec()\n    else:\n        raise","preventionTips":["Use exact registered names like 'RunInference'","Check _transform_constructors for the installed Beam version","Match casing exactly; type names are case-sensitive"],"tags":["python","apache-beam","yaml","ml","invalid-enum"],"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-14T16:17:12.679Z"}