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] Returning data in different types #267

Closed
czarekk215 opened this issue Oct 28, 2024 · 5 comments
Closed

[Bug] Returning data in different types #267

czarekk215 opened this issue Oct 28, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@czarekk215
Copy link
Contributor

Describe the bug

I switched from zenoh 0.11.0 to 1.0.0 version. I use influxdb v1 to store data from ros2 node. Ask Rest api to get data from db returns valued in different formats like:

{"key":"sensor_publisher_temp","value":"aW52YWxpZCB1dGYtOCBzZXF1ZW5jZSBvZiAxIGJ5dGVzIGZyb20gaW5kZXggNzA=","encoding":"zenoh/bytes","timestamp":"7429687337599560704/ab85ed18b7c453d6849c2e1b759f2f57"},{"key":"sensor_publisher_temp","value":"aW52YWxpZCB1dGYtOCBzZXF1ZW5jZSBvZiAxIGJ5dGVzIGZyb20gaW5kZXggNzA=","encoding":"zenoh/bytes","timestamp":"7429687337599714432/ab85ed18b7c453d6849c2e1b759f2f57"},{"key":"sensor_publisher_temp","value":"aW52YWxpZCB1dGYtOCBzZXF1ZW5jZSBvZiAxIGJ5dGVzIGZyb20gaW5kZXggNzA=","encoding":"zenoh/bytes","timestamp":"7429687337599736448/ab85ed18b7c453d6849c2e1b759f2f57"},{"key":"sensor_publisher_temp","value":"AAEAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAABRCAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","encoding":"zenoh/bytes","timestamp":"7429687346189489808/ab85ed18b7c453d6849c2e1b759f2f57"},{"key":"sensor_publisher_temp","value":"AAEAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAABRCAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","encoding":"zenoh/bytes","timestamp":"7429687346189910368/ab85ed18b7c453d6849c2e1b759f2f57"},

On version 0.11.0 every row was the same format, because now values has different format it's hard to deserialize the in the sam way.

To reproduce

  1. Start influxdb v1
  2. Start Zenoh server with zenoh-backend-ifnluxdb
  3. Start zenoh-ros2-bridge
  4. Start ros2 publisher
  5. Rest api ask to get data

System info

  • Platform Ubuntu 22.04
  • Zenoh version 1.0.0
@czarekk215 czarekk215 added the bug Something isn't working label Oct 28, 2024
@mangodan2003
Copy link
Contributor

mangodan2003 commented Nov 19, 2024

It looks like this is basically the same as what I was about to report, though the description is unclear. Basically it seems that if you try to store binary data it gets incorrectly interpreted as utf-8 which fails, and the result is that the db holds a record that is a base64 encoded string saying that it failed to interpret the data as utf-8:

aW52YWxpZCB1dGYtOCBzZXF1ZW5jZSBvZiAxIGJ5dGVzIGZyb20gaW5kZXggNzA => "invalid utf-8 sequence of 1 bytes from index 70"

To reproduce

  1. setup zenoh storage for influxdb
  2. create a publisher and use it to write a binary value (that does not represent a valid utf-8 string)
  3. try and get the value back, or use influx client and select * from path/to/something

@mangodan2003
Copy link
Contributor

mangodan2003 commented Nov 21, 2024

Here's the culprit

https://github.com/eclipse-zenoh/zenoh-backend-influxdb/blob/main/v1/src/lib.rs#L446

Changing to this makes it work
Err(err) => (true, b64_std_engine.encode(payload.to_bytes()).into()),
I made a PR #284

@adamkrawczyk
Copy link

Any updates in this area?

@mangodan2003
Copy link
Contributor

This fix has just been merged into main : 1095b3c

@JEnoch
Copy link
Member

JEnoch commented Dec 6, 2024

Fixed by #284. Thanks @mangodan2003 !

@JEnoch JEnoch closed this as completed Dec 6, 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

4 participants