[ 
https://issues.apache.org/jira/browse/AVRO-3240?focusedWorklogId=669447&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-669447
 ]

ASF GitHub Bot logged work on AVRO-3240:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Oct/21 10:31
            Start Date: 25/Oct/21 10:31
    Worklog Time Spent: 10m 
      Work Description: ultrabug commented on pull request #1379:
URL: https://github.com/apache/avro/pull/1379#issuecomment-950775660


   Ok @martin-g in my quest to write a test for this (I fail so far) I found 
something that I clearly do not understand but which triggers the same Error 
than my initial problem here.
   
   Disclaimer : I'm not sure if they are related, but since I don't understand 
how to fix this failing test below, I dunno...
   
   Basically, you can't call `from_avro_datum` multiple times on the same 
reader :
   
   ```
   #[test]
       fn test_from_avro_datum_multiple() {
           let schema = Schema::parse_str(SCHEMA).unwrap();
           let mut encoded: &'static [u8] = &[54, 6, 102, 111, 111];
   
           let mut record = Record::new(&schema).unwrap();
           record.put("a", 27i64);
           record.put("b", "foo");
           let expected = record.into();
   
           from_avro_datum(&schema, &mut encoded, None).unwrap();
   
           assert_eq!(
               from_avro_datum(&schema, &mut encoded, None).unwrap(),
               expected
           );
   ```


-- 
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-unsubscr...@avro.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 669447)
    Time Spent: 40m  (was: 0.5h)

> Schema deserialization is not backwards compatible
> --------------------------------------------------
>
>                 Key: AVRO-3240
>                 URL: https://issues.apache.org/jira/browse/AVRO-3240
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: rust
>            Reporter: Ultrabug
>            Priority: Critical
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Hello,
>  
> When providing your own schema to `from_avro_datum`, the deserialization is 
> not backward compatible with messages containing a previous schema even if 
> the schemas are created to be backward compatible.
> This is due to the `decode_variable` function in `utils` returning 
> `Error::ReadVariableIntegerBytes` when the reader object is smaller than 
> expected when reading a message with previous schema version (which is indeed 
> smaller) and trying to decode it with a backward compatible schema.
> I have fixed the issue locally with the following patch which I will submit 
> as a PR
>  
> ```
> diff --git a/lang/rust/src/util.rs b/lang/rust/src/util.rs
> index f9daf285..3538399e 100644
> --- a/lang/rust/src/util.rs
> +++ b/lang/rust/src/util.rs
> @@ -96,7 +96,7 @@ fn decode_variable<R: Read>(reader: &mut R) -> 
> AvroResult<u64> {
>  }
>  reader
>  .read_exact(&mut buf[..])
> - .map_err(Error::ReadVariableIntegerBytes)?;
> + .or(Ok(()))?; // return nullable to support avro schemas backward 
> compatibility
>  i |= (u64::from(buf[0] & 0x7F)) << (j * 7);
>  if (buf[0] >> 7) == 0 {
>  break;
> ```



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to