You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/12/14 10:32:00 UTC

[jira] [Work logged] (AVRO-3263) Perl Encoder: schema validation of union of records warns when passing over an invalid schema with a long field

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

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

                Author: ASF GitHub Bot
            Created on: 14/Dec/21 10:31
            Start Date: 14/Dec/21 10:31
    Worklog Time Spent: 10m 
      Work Description: martin-g commented on a change in pull request #1422:
URL: https://github.com/apache/avro/pull/1422#discussion_r768527697



##########
File path: lang/perl/lib/Avro/Schema.pm
##########
@@ -284,6 +284,7 @@ sub is_data_valid {
     }
     if ($type eq 'long') {
         if ($Config{use64bitint}) {
+            no warnings;

Review comment:
       Wouldn't be better to check whether `$data` is defined/initialized ?




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

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


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

            Worklog Id:     (was: 695625)
    Remaining Estimate: 1h 50m  (was: 2h)
            Time Spent: 10m

> Perl Encoder: schema validation of union of records warns when passing over an invalid schema with a long field
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-3263
>                 URL: https://issues.apache.org/jira/browse/AVRO-3263
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: perl
>            Reporter: Miguel
>            Assignee: Miguel
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.11.1
>
>   Original Estimate: 2h
>          Time Spent: 10m
>  Remaining Estimate: 1h 50m
>
> When searching for a valid schema to encode a field that is a union of records, the Perl encoder warns if the payload doesn't contain a _long_ field required in one of the records' schemas.
> Example. The following snippet:
> {code:perl}
> my $schema = Avro::Schema->parse(<<EOJ);
> [
>     {
>         "type": "record",
>         "name": "rectangle",
>         "fields": [{ "name": "width", "type": "long" }, { "name": "height", "type": "long"}]
>     },
>     {
>         "type": "record",
>         "name": "square",
>         "fields": [{ "name": "dim", "type": "long" }]
>     }
> ]
> EOJ
> my $enc = '';
> Avro::BinaryEncoder->encode(
>     schema  => $schema,
>     data    => { dim => 10 },
>     emit_cb => sub {
>         $enc .= ${ $_[0] }
>     },
> );
> {code}
> Throws the following warnings:
> {code:java}
> Use of uninitialized value $data in pack at ...avro/lang/perl/lib/Avro/Schema.pm line 287.
> Use of uninitialized value $data in string eq at ...avro/lang/perl/lib/Avro/Schema.pm line 289.
> {code}
> The same doesn't happen if _width_ and _height_ are _int_'s.
> This behavior unnecessarily pollutes the logs and can even cause failures in the cases where the encoder is called from a context that doesn't allow warnings.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)