You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "alambov-md (via GitHub)" <gi...@apache.org> on 2026/01/26 14:48:04 UTC
[I] Schema type for `Uuid` type is overridden by `set_serde_human_readable()` parameter on serialization [avro-rs]
alambov-md opened a new issue, #440:
URL: https://github.com/apache/avro-rs/issues/440
Hello team!
Apache Avro Specification states that:
> A `uuid` logical type annotates an Avro `string` or `fixed` of length 16.
However, in the current mainline (#6218cd7) schema requirements for underlying type are ignored on uuids serialisation, and the type depends on `apache_avro::util::set_serde_human_readable()` parameter: when `true` uuids are serialised into strings, when `false` - into bytes.
This behaviour differs from latest released version `rel/release-0.21.0`, where the type depends on the schema.
It seems the behaviour from `rel/release-0.21.0` is more correct. Could it be restored?
Attaching here an integration test for convenience.
```rust
use apache_avro::{Reader, Schema, Uuid, Writer};
use std::error::Error;
#[test]
fn test_uuid_serliazation_deserialization() -> Result<(), Box<dyn Error>> {
// This line makes the test to pass.
// Currently it's passigng only with `set_serde_human_readable(true)`
// It worked correctly both with `true` an `false in `rel/release-0.21.0`.
// apache_avro::util::set_serde_human_readable(false);
let raw_schema = r#"
{
"name": "uuid",
"type": "string",
"logicalType": "uuid"
}
"#;
let schema = Schema::parse_str(raw_schema)?;
let initial_id = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let mut writer = Writer::new(&schema, Vec::new())?;
writer.append_ser(&initial_id)?;
let input = writer.into_inner()?;
let reader = Reader::with_schema(&schema, &input[..])?;
for value in reader {
println!("{value:?}");
assert_eq!(initial_id, apache_avro::from_value::<Uuid>(&value?)?);
}
Ok(())
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Schema type for `Uuid` type is overridden by `set_serde_human_readable()` parameter on serialization [avro-rs]
Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on issue #440:
URL: https://github.com/apache/avro-rs/issues/440#issuecomment-3800336693
It did not work correctly in 0.21.0 (and before).
If `serde_human_readable` was set to `true` it would allways output a string (even if the schema was bytes) and if it was set to `false` it would always output a bytes (not a fixed!):
| human_readable | Uuid |
| - | - |
| `true` | `string` |
| `false` | `bytes` |
In 0.22.0 it will do the following:
| human_readable | Uuid (String) | Uuid (Bytes) | Uuid (Fixed) |
| - | - | - | - |
| `true` | `string` | `Err` | `Err` |
| `false` | `bytes`* | `bytes` | `fixed` |
\* This is a bug and will be fixed, it should be `Err`
What you want is not possible. We don't get a `Uuid` from Serde. We get a string if `human_readable` is `true` (like `550e8400-e29b-41d4-a716-446655440000`) or we bytes when `human_readable` is `false` (like `[171, 27, 146, 24, 38, 212, 254, 206, 21, 172, 18, 139, 191, 244, 27, 226]`). So we can't choose the input to match what the schema expects.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Schema type for `Uuid` type is overridden by `set_serde_human_readable()` parameter on serialization [avro-rs]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g closed issue #440: Schema type for `Uuid` type is overridden by `set_serde_human_readable()` parameter on serialization
URL: https://github.com/apache/avro-rs/issues/440
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Schema type for `Uuid` type is overridden by `set_serde_human_readable()` parameter on serialization [avro-rs]
Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on issue #440:
URL: https://github.com/apache/avro-rs/issues/440#issuecomment-3801258440
Yes, that is correct.
Yes, that would be a good option.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Schema type for `Uuid` type is overridden by `set_serde_human_readable()` parameter on serialization [avro-rs]
Posted by "alambov-md (via GitHub)" <gi...@apache.org>.
alambov-md commented on issue #440:
URL: https://github.com/apache/avro-rs/issues/440#issuecomment-3800470399
Hi @Kriskras99, technically the serialization result is defined not by `serde`, but by `uuid` crate [here](https://github.com/uuid-rs/uuid/blob/c3346ddf2a78ecadefbadaa83d22e263342745ca/src/external/serde_support.rs#L28), but I see what you mean.
So just to understand, the expected behaviour is to produce errors when schema and serialisation results don't match?
Additionally, do you see a custom `Serialize` implementation (for an struct with `Uuid` field for example) as a good way to ensure the serialisation result is aligned with the schema for both `serde_human_readable` `true` and `false`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org