{"record":{"id":"2804ed195b48acc2","repo":"apache/beam","slug":"unrecognized-atomic-type-atomic-type-when-encoding-value","errorCode":null,"errorMessage":"Unrecognized atomic_type {atomic_type} when encoding value {value}","messagePattern":"Unrecognized atomic_type (.+?) when encoding value (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/typehints/schemas.py","lineNumber":480,"sourceCode":"      atomic_value = schema_pb2.AtomicTypeValue(byte=value)\n    elif atomic_type == schema_pb2.INT16:\n      atomic_value = schema_pb2.AtomicTypeValue(int16=value)\n    elif atomic_type == schema_pb2.INT32:\n      atomic_value = schema_pb2.AtomicTypeValue(int32=value)\n    elif atomic_type == schema_pb2.INT64:\n      atomic_value = schema_pb2.AtomicTypeValue(int64=value)\n    elif atomic_type == schema_pb2.FLOAT:\n      atomic_value = schema_pb2.AtomicTypeValue(float=value)\n    elif atomic_type == schema_pb2.DOUBLE:\n      atomic_value = schema_pb2.AtomicTypeValue(double=value)\n    elif atomic_type == schema_pb2.STRING:\n      atomic_value = schema_pb2.AtomicTypeValue(string=value)\n    elif atomic_type == schema_pb2.BOOLEAN:\n      atomic_value = schema_pb2.AtomicTypeValue(boolean=value)\n    elif atomic_type == schema_pb2.BYTES:\n      atomic_value = schema_pb2.AtomicTypeValue(bytes=value)\n    else:\n      raise ValueError(\n          \"Unrecognized atomic_type {atomic_type} when encoding value {value}\")\n\n    return atomic_value\n\n  def value_from_runner_api(\n      self,\n      type_proto: schema_pb2.FieldType,\n      value_proto: schema_pb2.FieldValue):\n    type_info = type_proto.WhichOneof(\"type_info\")\n    if type_info == \"atomic_type\":\n      return self.atomic_value_from_runner_api(\n          type_proto.atomic_type, value_proto.atomic_value)\n    elif type_info == \"array_type\":\n      element_type = type_proto.array_type.element_type\n      return [\n          self.value_from_runner_api(element_type, element)\n          for element in value_proto.array_value.element\n      ]","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/typehints/schemas.py#L462-L498","documentation":"`atomic_value_to_runner_api` maps a Python scalar to its AtomicTypeValue proto based on the resolved atomic_type; only STRING, INT, DOUBLE, BOOLEAN, BYTES are handled. Note the message lacks f-strings, so the placeholders print literally. Any other field type produces this ValueError.","triggerScenarios":"Calling `value_to_runner_api` with a value whose inferred atomic_type isn't one of the five supported kinds, e.g. an unsupported scalar like a complex number or numpy scalar being converted to a schema option/field.","commonSituations":"Passing numpy scalars (np.int32) or datetimes directly as option values; converting schemas with exotic field types between SDKs.","solutions":["Convert the value to a supported Python scalar (int, float, str, bool, bytes) before setting it","Use an appropriate logical/annotation type or restructure the field so it maps to a supported atomic type","Upgrade Beam if a newer version supports your value's type"],"exampleFix":"// before\noption = Option('ts', value=np.datetime64('2024-01-01'))\n// after\noption = Option('ts', value='2024-01-01')  # encode as string","handlingStrategy":"validation","validationCode":"if not isinstance(value, (str, int, float, bool, bytes)):\n  raise TypeError('option value must be a supported atomic scalar')","typeGuard":"def is_atomic_scalar(v) -> bool:\n  return isinstance(v, (str, int, float, bool, bytes))","tryCatchPattern":"try:\n  opt = option_to_runner_api(opt)\nexcept ValueError:\n  opt = option_to_runner_api(Option(opt.name, value=str(opt.value)))","preventionTips":["Coerce numpy scalars and datetimes to native Python types","Only use str/int/float/bool/bytes for schema options"],"tags":["python","schema","protobuf","encoding"],"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-20T03:17:13.778Z"}