flavray / avro-rs

Avro client library implementation in Rust
MIT License
169 stars 95 forks source link

Comparing schemas can panic in 0.11.0 #159

Closed lerouxrgd closed 3 years ago

lerouxrgd commented 3 years ago

Here is an example:

use avro_rs::*;

fn main() {
    let raw_schema = r#"
{
  "type": "record",
  "name": "User",
  "doc": "Hi there.",
  "fields": [
    {"name": "likes_pizza", "type": "boolean", "default": false},
    {"name": "aa-i32",
     "type": {"type": "array", "items": {"type": "array", "items": "int"}},
     "default": [[0], [12, -1]]}
  ]
}
    "#;

    let schema = Schema::parse_str(raw_schema).unwrap();
    let schema2 = schema.clone();

    println!("{:?}", schema == schema2); // this panics
}

If I remove {"name": "likes_pizza", "type": "boolean", "default": false} then it does not panic.

This is a regression that was likely introduced in 0.11.0 as it still works in 0.10.0.