{"record":{"id":"f8c2224b4f77ba77","repo":"apache/beam","slug":"failed-to-decode-schema-due-to-an-issue-with-field-proto","errorCode":null,"errorMessage":"Failed to decode schema due to an issue with Field proto:\n\n{text_format.MessageToString(field)}","messagePattern":"Failed to decode schema due to an issue with Field proto:\n\n(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/typehints/schemas.py","lineNumber":641,"sourceCode":"          fieldtype_proto.iterable_type.element_type)]\n\n    else:\n      raise ValueError(f\"Unrecognized type_info: {type_info!r}\")\n\n  def named_tuple_from_schema(self, schema: schema_pb2.Schema) -> type:\n    from apache_beam import coders\n\n    type_name = 'BeamSchema_{}'.format(schema.id.replace('-', '_'))\n\n    subfields = []\n    descriptions = {}\n    for field in schema.fields:\n      try:\n        field_py_type = self.typing_from_runner_api(field.type)\n        if isinstance(field_py_type, row_type.RowTypeConstraint):\n          field_py_type = field_py_type.user_type\n      except ValueError as e:\n        raise ValueError(\n            \"Failed to decode schema due to an issue with Field proto:\\n\\n\"\n            f\"{text_format.MessageToString(field)}\") from e\n\n      descriptions[field.name] = field.description\n      subfields.append((field.name, field_py_type))\n\n    if schema.id in self.schema_registry.by_id:\n      user_type = self.schema_registry.by_id[schema.id][0]\n    else:\n      user_type = NamedTuple(type_name, subfields)\n\n      # Define a reduce function, otherwise these types can't be pickled\n      # (See BEAM-9574)\n      setattr(\n          user_type,\n          '__reduce__',\n          _named_tuple_reduce_method(schema.SerializeToString()))\n      setattr(user_type, \"_field_descriptions\", descriptions)","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/typehints/schemas.py#L623-L659","documentation":"`named_tuple_from_schema` converts each Field proto to a Python type; if any field's type conversion raises ValueError, it is re-raised with the full field proto text appended, so the developer can see exactly which field proto failed. This is a wrapping diagnostic for errors like unknown atomic types or type_info values.","triggerScenarios":"Calling `named_tuple_from_schema` (directly or via union_schema_type / _hydrate_namedtuple_instance) on a Schema proto containing at least one Field whose type cannot be converted to a Python typing.","commonSituations":"Cross-language schemas with unsupported field types; stale protos from newer SDK versions; corrupted serialized schemas.","solutions":["Read the embedded field proto in the message to find the offending field","Fix or drop that field from the schema, or convert it to a supported type","Upgrade apache-beam so the field's type is supported"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for f in schema.fields:\n  try:\n    converter.typing_from_runner_api(f.type)\n  except ValueError as e:\n    raise ValueError(f'bad field {f.name}: {e}')","typeGuard":null,"tryCatchPattern":"try:\n  Row = converter.named_tuple_from_schema(schema)\nexcept ValueError as e:\n  log.error(str(e))  # message contains the offending Field proto\n  raise","preventionTips":["Inspect the embedded Field proto text in the error to locate the bad field","Validate schemas at pipeline-construction time, not at runtime hydration"],"tags":["python","schema","namedtuple","protobuf"],"backgroundTag":"schema-validation-failed","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"}