{"record":{"id":"a6dbd888f63c8a8c","repo":"apache/beam","slug":"invalid-value-type-for-type-it-must-be-a-dict-or-a-str","errorCode":null,"errorMessage":"Invalid value \"{type}\" for \"type\". It must be a dict or a str.","messagePattern":"Invalid value \"(.+?)\" for \"type\"\\. It must be a dict or a str\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_join.py","lineNumber":39,"sourceCode":"from typing import Union\n\nimport apache_beam as beam\nfrom apache_beam.yaml import yaml_provider\n\n\ndef _validate_input(pcolls):\n  error_prefix = f'Invalid input {pcolls} specified.'\n  if not isinstance(pcolls, dict):\n    raise ValueError(f'{error_prefix} It must be a dict.')\n  if len(pcolls) < 2:\n    raise ValueError(\n        f'{error_prefix} There should be at least 2 inputs to join.')\n\n\ndef _validate_type(type, pcolls):\n  error_prefix = f'Invalid value \"{type}\" for \"type\".'\n  if not isinstance(type, dict) and not isinstance(type, str):\n    raise ValueError(f'{error_prefix} It must be a dict or a str.')\n  if isinstance(type, dict):\n    error = ValueError(\n        f'{error_prefix} When specifying a dict for type, '\n        f'it must follow this format: '\n        f'{{\"outer\": [list of inputs to outer join]}}. '\n        f'Example: {{\"outer\": [\"input1\", \"input2\"]}}')\n    if (len(type) != 1 or next(iter(type)) != 'outer' or\n        not isinstance(type['outer'], list)):\n      raise error\n    for input in type['outer']:\n      if input not in list(pcolls.keys()):\n        raise ValueError(\n            f'{error_prefix} An invalid input \"{input}\" was specified.')\n  if isinstance(type, str) and type not in ('inner', 'outer', 'left', 'right'):\n    raise ValueError(\n        f'{error_prefix} When specifying the value for type as a str, '\n        f'it must be one of the following: \"inner\", \"outer\", \"left\", \"right\"')\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_join.py#L21-L57","documentation":"Thrown by _validate_type in apache_beam/yaml/yaml_join.py when the join 'type' parameter is neither a dict (outer-join specification) nor a str (inner/outer/left/right). Any other type (list, int, None, etc.) is rejected.","triggerScenarios":"Setting type: to a list, number, boolean, or null in the Join transform config; programmatically passing a non-str non-dict object as the type argument.","commonSituations":"YAML typos like type: [inner]; quoting errors making the value an array; passing Python None when the key is required.","solutions":["Set type to one of the strings 'inner', 'outer', 'left', 'right'.","Or use a dict of the form {'outer': [list of input tags]} for outer joins.","Quote string values in YAML so they are not misparsed."],"exampleFix":"// before\ntype: [inner]\n// after\ntype: inner","handlingStrategy":"validation","validationCode":"if not (isinstance(t, str) or isinstance(t, dict)):\n    raise TypeError(\"Join 'type' must be 'inner'|'outer'|'left'|'right' or {'outer': [...]}\")","typeGuard":"def is_valid_join_type(t):\n    return (isinstance(t, str) and t in ('inner', 'outer', 'left', 'right')) or isinstance(t, dict)","tryCatchPattern":null,"preventionTips":["Quote string values in YAML to avoid mis-parsing","Use only the four documented string values or the outer-dict form","Add schema validation of the YAML spec before submission"],"tags":["apache-beam","yaml","join","validation"],"backgroundTag":"type-mismatch","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"}