Not supporting AVRO schema with default null value
From your provided stacktrace, it appears that you’re running into an INVALID_ARGUMENT
error due to a schema validation failure, when trying to publish a non-null (i.e., string) value to a Pub/Sub topic.
This error typically occurs when the data being published does not match the schema defined for the topic. With the Avro schema that you’re using, both null
and string
values should be valid for the field1
field.
There could be an issue with how the data is being serialized before it’s being published to the topic. In Avro, if a field is declared as a union of types, the data for that field needs to be serialized as a JSON object where the key is the type and the value is the actual value. So, for a string value, it should look like this:
{
“field1”: {“string”: “your string value”}
}
This is in contrast to a null
value, which can simply be serialized as:
{
“field1”: null
}
Read more here: Source link