You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by kr...@apache.org on 2026/02/11 10:39:29 UTC

(avro-rs) branch fix/suggest_boolean_for_bool updated (d9016f0 -> cebcdf4)

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

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


 discard d9016f0  fix: Suggest `boolean` when `bool` is used
     new cebcdf4  fix: Suggest `boolean` when `bool` is used

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d9016f0)
            \
             N -- N -- N   refs/heads/fix/suggest_boolean_for_bool (cebcdf4)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 avro/src/schema/mod.rs | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)


(avro-rs) 01/01: fix: Suggest `boolean` when `bool` is used

Posted by kr...@apache.org.
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 <gi...@kriskras99.nl>
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)?;