thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
221 stars 54 forks source link

Cumulocity operation failureReason field cannot contain quotes #2487

Closed jarhodes314 closed 10 months ago

jarhodes314 commented 11 months ago

Is your feature improvement request related to a problem? Please describe. In #2474, I modified the code to debug print some values in errors that later get turned into failure reasons for operations. I was surprised to discover that the mapper removes quotes from failure reasons when serialising them to SmartREST, so this didn't work as intended.

Describe the solution you'd like Quotes in the error message should be preserved when they are sent to Cumulocity.

Describe alternatives you've considered

Additional context

rina23q commented 11 months ago

Double quotes in failure reason must be escaped by two double quotes like below.

502,c8y_UploadConfigFile,"contains""double""quote"

This sanitize function escapes double quotes by two double quotes, so maybe our failure reason generation doesn't use this function? https://github.com/thin-edge/thin-edge.io/blob/b2162397cfef4c73dd7d5b794fdd3adb6d55b604/crates/core/c8y_api/src/smartrest/message.rs#L37-L46

jarhodes314 commented 10 months ago

@gligorisaev I'm hoping the examples from the robot test changes in https://github.com/thin-edge/thin-edge.io/pull/2493/files are sufficient for you to understand what this change affects in tedge and to reproduce it.

gligorisaev commented 10 months ago

QA has thoroughly checked the feature and here are the results: