{"record":{"id":"277bd6d6bc3665a8","repo":"apache/beam","slug":"only-atomic-type-and-array-type-option-values-are-currently","errorCode":null,"errorMessage":"Only atomic_type and array_type option values are currently supported in Python. Got {value!r}, which maps to fieldtype {typing_proto!r}.","messagePattern":"Only atomic_type and array_type option values are currently supported in Python\\. Got (.+?), which maps to fieldtype (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/typehints/schemas.py","lineNumber":519,"sourceCode":"          \"Encountered option with unsupported type. Only atomic_type and \"\n          f\"array_type options are supported: {type_proto}\")\n\n  def value_to_runner_api(self, typing_proto: schema_pb2.FieldType, value):\n    type_info = typing_proto.WhichOneof(\"type_info\")\n    if type_info == \"atomic_type\":\n      return schema_pb2.FieldValue(\n          atomic_value=self.atomic_value_to_runner_api(\n              typing_proto.atomic_type, value))\n    elif type_info == \"array_type\":\n      element_type = typing_proto.array_type.element_type\n      return schema_pb2.FieldValue(\n          array_value=schema_pb2.ArrayTypeValue(\n              element=[\n                  self.value_to_runner_api(element_type, element)\n                  for element in value\n              ]))\n    else:\n      raise ValueError(\n          \"Only atomic_type and array_type option values are currently \"\n          f\"supported in Python. Got {value!r}, which maps to fieldtype \"\n          f\"{typing_proto!r}.\")\n\n  def option_from_runner_api(\n      self, option_proto: schema_pb2.Option) -> Tuple[str, Any]:\n    if not option_proto.HasField('type'):\n      return option_proto.name, None\n\n    value = self.value_from_runner_api(option_proto.type, option_proto.value)\n    return option_proto.name, value\n\n  def option_to_runner_api(self, option: Tuple[str, Any]) -> schema_pb2.Option:\n    name, value = option\n\n    if value is None:\n      # a value of None indicates the option is just a flag.\n      # Don't set type, value","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/typehints/schemas.py#L501-L537","documentation":"`value_to_runner_api` can only serialize Python option values that map to atomic_type (scalars) or array_type (lists). Anything else — dicts, rows, nested structures — has no supported proto mapping and raises this ValueError.","triggerScenarios":"Calling `value_to_runner_api` (via `option_to_runner_api` or a schema option with e.g. a dict or namedtuple value) where the inferred FieldType is not atomic or array.","commonSituations":"Setting a pipeline option or schema option to a dict/struct in Python; passing rich objects as options in cross-language pipelines.","solutions":["Serialize the value to a supported type yourself (e.g. JSON string or flat list) before setting the option","Use primitives (str/int/float/bool/bytes) or flat lists of primitives","Restructure the data so it doesn't need to travel as an option"],"exampleFix":"// before\nrow.RowTypeConstraint option value: Option('conf', value={'k': 1})\n// after\nimport json; Option('conf', value=json.dumps({'k': 1}))","handlingStrategy":"validation","validationCode":"if isinstance(value, (dict, tuple)) or hasattr(value, '_asdict'):\n  value = json.dumps(value)  # pre-serialize before schema conversion","typeGuard":"def is_option_supported(v) -> bool:\n  return isinstance(v, (str, int, float, bool, bytes, list))","tryCatchPattern":"try:\n  proto = converter.value_to_runner_api(tp, value)\nexcept ValueError:\n  proto = converter.value_to_runner_api(tp, json.dumps(value, default=str))","preventionTips":["Serialize dicts/objects to JSON strings before using as options","Limit option values to scalars and flat lists"],"tags":["python","schema","options","serialization"],"backgroundTag":"unsupported-operation","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"}