Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Consuming raw bytes with CLI return incorrect data #3967

Open
nacardin opened this issue Apr 24, 2024 · 0 comments
Open

[Bug]: Consuming raw bytes with CLI return incorrect data #3967

nacardin opened this issue Apr 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@nacardin
Copy link
Contributor

Steps to reproduce:

  1. Create a file test.bin with the following bytes 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0xF0, 0x90, 0x80, 0x57, 0x6F, 0x72, 0x6C, 0x64. This is from https://doc.rust-lang.org/std/string/struct.String.html#method.from_utf8_lossy "Incorrect bytes" example
$ fluvio produce bin-test --raw -f test.bin
$ fluvio consume -B bin-test -O raw > test-output.bin

In the test-output.bin file, the bytes will be 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0xEF, 0xBF, 0xBD, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x0A. 0xF0, 0x90, 0x80 is replaced by 0xEF, 0xBF, 0xBD.

I believe this happens to the inappropriate use of from_utf8_lossy in

String::from_utf8_lossy(record).to_string()

This is binary data, it should not be parsed as utf8.

@nacardin nacardin added the bug Something isn't working label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant