Skip to content

Fix panic in image filtering#1879

Merged
jhump merged 1 commit intomainfrom
jh/fix-panic
Mar 3, 2023
Merged

Fix panic in image filtering#1879
jhump merged 1 commit intomainfrom
jh/fix-panic

Conversation

@jhump
Copy link
Member

@jhump jhump commented Mar 2, 2023

🤦 Caught this while on-call. It happened in production when the BSR was handling an ImageService.GetImage request. I think this means use of -type param with buf build and buf generate will crash if the schema contains maps whose values are not message types 😢. So we'll probably want to create a patch release of the Buf CLI, too.

Fixes BSR-1543

return true
})
return err
case fd.IsMap():
Copy link
Member Author

@jhump jhump Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For map fields whose value was not a map, it would previously fall-through and end up getting to line 760, where it would blow up with this:

type mismatch: cannot convert map to message

The value type is actually a map. But we end up calling the val.Message() method. Oops.

So now, if it's a map whose value is not a message, it will no longer fall-through due to the condition change here.

@jhump jhump requested a review from unmultimedio March 2, 2023 21:04
Copy link
Member

@unmultimedio unmultimedio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, although not sure if you want another review from someone more familiar with FileDescriptors than me? 😅

@jhump
Copy link
Member Author

jhump commented Mar 3, 2023

not sure if you want another review from someone more familiar with FileDescriptors than me?

LOL, Robbert was my go to reviewer for this stuff before this week.

Maybe @bufdev or @srikrsna-buf?

@jhump jhump merged commit 062bcf5 into main Mar 3, 2023
@jhump jhump deleted the jh/fix-panic branch March 3, 2023 13:18
@jhump
Copy link
Member Author

jhump commented Mar 3, 2023

@bufdev, I merged but just realized that this might be changelog-worthy since it fixes a crash. WDYT? If you agree, I'll open another PR w/ the changelog note. And then we should probably cut a point release. (The only other change to the CLI since v1.15.0 is #1874 which doesn't seem minor-version-worthy.)

Monirul1 pushed a commit to Monirul1/buf that referenced this pull request Apr 30, 2023
Imagine filtering could panic with "type mismatch: cannot convert map to message"
for sources that have map fields where the map value is not a message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants