Copilot commented on code in PR #3864:
URL: https://github.com/apache/avro/pull/3864#discussion_r3567458620


##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -323,8 +567,11 @@ sub skip_union {
     my $class = shift;
     my ($schema, $reader) = @_;
     my $idx = decode_long($class, undef, undef, $reader);
-    my $union_schema = $schema->schemas->[$idx]
-        or throw Avro::Schema::Error::Parse("union union member");
+    my $schemas = $schema->schemas;
+    if ($idx < 0 || $idx >= scalar @$schemas) {
+        throw Avro::Schema::Error::Parse("union union member");
+    }

Review Comment:
   In skip_union(), the out-of-range branch index error message is extremely 
generic ("union union member") and loses the actual index and branch count. 
Since decode_union() now emits a clear, structured message, skip_union should 
match it so callers get actionable diagnostics when skipping/projection 
encounters malformed data.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to