This is an automated email from the ASF dual-hosted git repository.

kriskras99 pushed a commit to branch fix/suggest_boolean_for_bool
in repository https://gitbox.apache.org/repos/asf/avro-rs.git

commit cebcdf4c3f28965c3bcc784426824cab8665ded9
Author: Kriskras99 <[email protected]>
AuthorDate: Wed Feb 11 11:33:58 2026 +0100

    fix: Suggest `boolean` when `bool` is used
---
 avro/src/error.rs         |  3 +++
 avro/src/schema/mod.rs    | 21 +++++++++++++++++++++
 avro/src/schema/parser.rs |  9 ++++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/avro/src/error.rs b/avro/src/error.rs
index ea81125..b3ff452 100644
--- a/avro/src/error.rs
+++ b/avro/src/error.rs
@@ -358,6 +358,9 @@ pub enum Details {
     #[error("Unknown primitive type: {0}")]
     ParsePrimitive(String),
 
+    #[error("Unknown primitive type: {0}, did you mean {1}?")]
+    ParsePrimitiveSimilar(String, &'static str),
+
     #[error("invalid JSON for {key:?}: {value:?}")]
     GetDecimalMetadataValueFromJson {
         key: String,
diff --git a/avro/src/schema/mod.rs b/avro/src/schema/mod.rs
index e2d67a3..b283731 100644
--- a/avro/src/schema/mod.rs
+++ b/avro/src/schema/mod.rs
@@ -5128,4 +5128,25 @@ mod tests {
         );
         Ok(())
     }
+
+    #[test]
+    fn avro_rs_456_bool_instead_of_boolean() -> TestResult {
+        let error = Schema::parse_str(
+            r#"{
+            "type": "record",
+            "name": "defaults",
+            "fields": [
+                {"name": "boolean", "type": "bool", "default": true}
+            ]
+        }"#,
+        )
+        .unwrap_err()
+        .into_details()
+        .to_string();
+        assert_eq!(
+            error,
+            Details::ParsePrimitiveSimilar("bool".to_string(), 
"boolean").to_string()
+        );
+        Ok(())
+    }
 }
diff --git a/avro/src/schema/parser.rs b/avro/src/schema/parser.rs
index 704f56b..eb1b849 100644
--- a/avro/src/schema/parser.rs
+++ b/avro/src/schema/parser.rs
@@ -187,7 +187,14 @@ impl Parser {
             .input_schemas
             .remove(&fully_qualified_name)
             // TODO make a better descriptive error message here that conveys 
that a named schema cannot be found
-            .ok_or_else(|| 
Details::ParsePrimitive(fully_qualified_name.fullname(None)))?;
+            .ok_or_else(|| {
+                let full_name = fully_qualified_name.fullname(None);
+                if full_name == "bool" {
+                    Details::ParsePrimitiveSimilar(full_name, "boolean")
+                } else {
+                    Details::ParsePrimitive(full_name)
+                }
+            })?;
 
         // parsing a full schema from inside another schema. Other full schema 
will not inherit namespace
         let parsed = self.parse(&value, &None)?;

Reply via email to