{"record":{"id":"071f1c2e8fcdb996","repo":"apache/beam","slug":"unexpected-parameters-in-model-handler-extra-params","errorCode":null,"errorMessage":"Unexpected parameters in model_handler: {extra_params}","messagePattern":"Unexpected parameters in model_handler: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_ml.py","lineNumber":558,"sourceCode":"      'inference'.\n    inference_args: Extra arguments for models whose inference call requires\n      extra parameters. Make sure to check the underlying ModelHandler docs to\n      see which args are allowed.\n\n  \"\"\"\n\n  options.YamlOptions.check_enabled(pcoll.pipeline, 'ML')\n\n  if not isinstance(model_handler, dict):\n    raise ValueError(\n        'Invalid model_handler specification. Expected dict but was '\n        f'{type(model_handler)}.')\n  expected_model_handler_params = {'type', 'config'}\n  given_model_handler_params = set(\n      SafeLineLoader.strip_metadata(model_handler).keys())\n  extra_params = given_model_handler_params - expected_model_handler_params\n  if extra_params:\n    raise ValueError(f'Unexpected parameters in model_handler: {extra_params}')\n  missing_params = expected_model_handler_params - given_model_handler_params\n  if missing_params:\n    raise ValueError(f'Missing parameters in model_handler: {missing_params}')\n  typ = model_handler['type']\n  model_handler_provider_type = ModelHandlerProvider.handler_types.get(\n      typ, None)\n  if not model_handler_provider_type:\n    raise NotImplementedError(f'Unknown model handler type: {typ}.')\n\n  model_handler_provider = ModelHandlerProvider.create_handler(model_handler)\n  model_handler_provider.validate(model_handler['config'])\n  schema = RowTypeConstraint.from_fields(\n      named_fields_from_element_type(pcoll.element_type) +\n      [(str(inference_tag), model_handler_provider.inference_output_type())])\n\n  return (\n      pcoll | RunInference(\n          model_handler=KeyedModelHandler(","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_ml.py#L540-L576","documentation":"After confirming model_handler is a dict, run_inference allows only the keys 'type' and 'config'. Any additional keys are collected into extra_params and reported in this ValueError listing the offending names.","triggerScenarios":"model_handler dict containing keys besides 'type' and 'config', e.g. {'type': 'VertexAI', 'endpoint_id': ..., 'project': ...} where handler options were placed at the top level instead of inside 'config'.","commonSituations":"Flattening handler options next to type in YAML; renaming config to something else; copying older YAML examples; JSON configs merging handler and endpoint settings.","solutions":["Move all handler options under the 'config' key","Keep only 'type' and 'config' at the model_handler level","Re-check YAML indentation so endpoint_id/project etc. are nested under config"],"exampleFix":"# before\nmodel_handler:\n  type: VertexAI\n  endpoint_id: '123'\n# after\nmodel_handler:\n  type: VertexAI\n  config:\n    endpoint_id: '123'","handlingStrategy":"validation","validationCode":"def check_handler_keys(handler):\n    extra = set(handler) - {'type', 'config'}\n    if extra:\n        raise ValueError(f'Move to config: {extra}')","typeGuard":"def has_only_expected_keys(h):\n    return isinstance(h, dict) and set(h) <= {'type', 'config'}","tryCatchPattern":null,"preventionTips":["Nest all handler options under 'config'","Never add sibling keys to 'type' in the model_handler mapping","Review YAML indentation with a linter"],"tags":["python","apache-beam","yaml","validation","ml"],"backgroundTag":"unexpected-config-key","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"}