You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/04/25 18:06:06 UTC
[avro] branch branch-1.11 updated: AVRO-3484: Followup Check default json parsing at compile time for derive macro (#1668)
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/branch-1.11 by this push:
new 0f0db7e0f AVRO-3484: Followup Check default json parsing at compile time for derive macro (#1668)
0f0db7e0f is described below
commit 0f0db7e0fb8c6905e66fb33b9918118bb8abd2ae
Author: Jack Klamer <jf...@gmail.com>
AuthorDate: Mon Apr 25 13:05:37 2022 -0500
AVRO-3484: Followup Check default json parsing at compile time for derive macro (#1668)
* check json parsing at compile time
* fmt
(cherry picked from commit 1343c80eba2f6685266d3cae67ca6281c5f7f4cf)
---
lang/rust/avro_derive/src/lib.rs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lang/rust/avro_derive/src/lib.rs b/lang/rust/avro_derive/src/lib.rs
index 423625375..149f85eaa 100644
--- a/lang/rust/avro_derive/src/lib.rs
+++ b/lang/rust/avro_derive/src/lib.rs
@@ -124,6 +124,13 @@ fn get_data_struct_schema_def(
let doc = preserve_optional(field_attrs.doc);
let default_value = match field_attrs.default {
Some(default_value) => {
+ let _: serde_json::Value = serde_json::from_str(&default_value[..])
+ .map_err(|e| {
+ vec![Error::new(
+ field.ident.span(),
+ format!("Invalid avro default json: \n{}", e),
+ )]
+ })?;
quote! {
Some(serde_json::from_str(#default_value).expect(format!("Invalid JSON: {:?}", #default_value).as_str()))
}