{"record":{"id":"0b5538ce72baab26","repo":"apache/beam","slug":"missing-type-in-ml-transform-spec-spec","errorCode":null,"errorMessage":"Missing type in ML transform spec {spec}","messagePattern":"Missing type in ML transform spec (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_ml.py","lineNumber":591,"sourceCode":"\n  return (\n      pcoll | RunInference(\n          model_handler=KeyedModelHandler(\n              model_handler_provider.underlying_handler()).with_preprocess_fn(\n                  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.')","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_ml.py#L573-L609","documentation":"_config_to_obj, which materializes ML transform providers from YAML specs, found no 'type' key in the spec dict; without it there is no provider class to look up, so the spec cannot be turned into a transform object.","triggerScenarios":"Passing an ml_transform spec dict (or the transform under yaml 'transforms') that lacks 'type', e.g. {'config': {...}} only.","commonSituations":"YAML indentation placing 'type' outside the transform mapping; omitting type when copying examples; building specs programmatically and forgetting the field.","solutions":["Add 'type' naming the ML transform, e.g. type: RunInference","Fix YAML indentation so type sits inside the transform spec","Validate the spec dict before constructing"],"exampleFix":"# before\n- name: inference\n  config: {model_handler: {...}}\n# after\n- name: inference\n  type: RunInference\n  config: {model_handler: {...}}","handlingStrategy":"validation","validationCode":"def check_spec(spec):\n    if 'type' not in spec:\n        raise ValueError(f'ML transform spec needs type: {spec}')","typeGuard":"def has_type(spec):\n    return isinstance(spec, dict) and 'type' in spec","tryCatchPattern":null,"preventionTips":["Always set 'type' in ML transform specs","Validate YAML pipeline specs before submission","Use a JSON schema for pipeline files"],"tags":["python","apache-beam","yaml","ml","validation"],"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-14T11:17:12.474Z"}