[Bug]: Logic in GetDynamicStringSegments function does not split string segments correctly when processing binary data which leads to exceptions during REST API queries #29150
Labels
Bug
Something isn't working
Community Reported
issues reported by community members
FE Coders Pod
Issues related to users writing javascript in appsmith
High
This issue blocks a user from building or impacts a lot of users
JS Evaluation
Issues related to JS evaluation on the platform
Needs Triaging
Needs attention from maintainers to triage
Production
Is there an existing issue for this?
Description
Hi,
We are trying to upload binary zip-files via a FilePicker Widget which triggers a PUT Query for this. Here, we noticed (at that point) "arbitrary" exceptions thrown when trying to upload certain zip files, which could be tracked back to the URL being set to "null" when trying to execute the query. After digging a bit deeper using the browsers console I was able to track the error back to the function "GetDynamicStringSegments" in the file: app/client/src/utils/DynamicBindingUtils.ts.
The reason for this is, that the implemented logic is counting the number of opened and closed curly brackets "{", ”}" in order to separate json objects into string segments. Unfortunately, the binary data might also contain these characters and therefore can lead to a wrong segmentation of the json objects. Whether or not the segmentation will be corrupted is dependent on the ratio of opened and closed curly brackets and therefore seemed arbitrary to us at first.
The wrong segmentation then caused that the resulting corrupt json object containing the request parameters could not be parsed properly and the function returned "null" for the url and the data used for the API REST query.
Here is a screenshot where above mentioned is visible, as the variable "sum" counting opened and closed brackets has the value -3 due to the binary zip-file data containing multiple "}" characters, but is expected to be >=0:
Steps To Reproduce
Public Sample App
No response
Environment
Release
Issue video log
No response
Version
Community 1.9.34
The text was updated successfully, but these errors were encountered: