openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[dart2] [client] Check request .bodyBytes, not .body

Open 0xNF opened this issue 2 years ago • 2 comments

fix #17546

This PR is part of the effort to split PR #17548

Changes request parsing from checking .body.isNotEmpty to .bodyBytes.isNotEmpty, because .body implicitly converts to a utf-8 string, and will crash when trying to deserde data that isn't valid utf-8.

@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

0xNF avatar Feb 07 '24 13:02 0xNF

How a byte array isn't a valid utf8 string(?)?

agilob avatar Feb 07 '24 19:02 agilob

No matching octet sequence or just unknown/invalid unicode. Makes sense to me, but can anyone test this? :)

kuhnroyal avatar Feb 15 '24 15:02 kuhnroyal

How a byte array isn't a valid utf8 string(?)?

For example, an endpoint that returns the bytes of a jpeg. Or an endpoint that serves utf16 strings.

In my case it was image data that caused exceptions, but endpoints can serve any encoding of byte, and every encoding is not valid utf8.

0xNF avatar Feb 19 '24 08:02 0xNF

for testing, we can consider adding echo api client for dart. We already have an endpoint to return a gif, we can create another endpoint to return a utf6 string.

@0xNF ping me if you need help adding the Dart echo api client to perform integration tests.

wing328 avatar Feb 19 '24 10:02 wing328