-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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]: JSON response gets stringified by server #22450
Comments
This commit fixes unexpected stringified JSON in the following plugins - REST API Plugin - GraphQL plugin - SaaS plugins (Airtable)
Issue with AirtableThe data returned by Airtable is in valid JSON format but after deserialization happens in Appsmith the
SolutionThe first deserialization is done by this piece of code
Airtable query results can be found as stringified JSON in the body (type object) field of |
Issue with RestApi and GraphQL pluginsIf the HTTP status code returned by the user's API server doesn't belong to 2xx then an error response is generated with plugin-specific code, Appsmith error message, and downstream error message. In this conversion, the actual response body gets stored in the downstreamErrorMessage field which is a string type. Thus a valid JSON response will get converted to stringified JSON if the HTTP status code doesn't belong to 2xx. SolutionThis extra piece of code is removed. Thus it ensures that the response returned by the user's API server will propagate to the front-end as is. |
So many users have already reported their apps aren't working as expected. Either they need to use Considering the above scenario I have added the |
Tested with TwilioFound that the response body in Twilio is basically a Hashmap in Java after the deserialization happens. So in this case the following deserialization suffices.
|
Regarding Airtable IssueLooking at the source code it seems we haven't made any changes recently. The last change was made almost 2 years ago. The Cypress test cases are also written in a way so that it expects stringified JSON and therefore, it uses And RiskIf make ship the changes regarding making the Airtable query result as valid JSON, that is going to be a breaking change for the aforementioned user group. |
Airtable user here (cloud). .data is now a string and not an object as before. But I'm pretty sure it was an object, since all the bindings in my app were working as query.data.fields[field_name] - and in my custom JS objects too. It's true that if I JSON.parse .data I have the correct object, but it means replacing query.data with JSON.parse( query.data ) everywhere in my app (tens of instances) Let's take a text field as an example. In my app I have something like {{ query.data.fields[field_name]}} and it used to work until v1.9.15-SNAPSHOT. I believe all airtable users did the same, since no JSON.parse was needed to get the .data content. I noticed the JSON.parse in the tests you are mentioning, and I found it weird too (and probably this is the reason this behaviour found its way to production: it passed the tests). Hope this helps! |
@lelesrc
Am I missing something? |
removed tags related to |
Can't explain this. Really. Basically, all of my bindings and functions were working until last update (1.9.15).
So, no clue! I don't have any valid explanation about how my code used to work until 1.9.15 (but I'm sure it did, since I had many end users using my app). The bottom line is that It's not a big deal to update my app code to JSON.parse .data - as long as this won't change back in the future. As a side consideration, under a UX perspective, using JSON.parse in every binding dialogue could be sub-optimal in terms of clarity (and probably not immediate for most users). I only use airtable as a datasource, so I don't know if parsing is needed when binding using other integrations. In this case, consistency would be the best design choice. Thank you for tackling this issue, I'm available for testing if you need! |
@lelesrc However, while we are trying to come up with the best solution can you please check whether the Airtable query result is giving the expected output in the following deploy-preview? https://ce-22498.dp.appsmith.com (Note: You need to sign up) Would really appreciate your feedback! |
I put up the simplest test case I came up with on ce-22498.dp.appsmith.com:
It works as expected, the record id is printed. The data object is an object.
data returned by the getId function is an object. As a counter-example, I did the same on 1.9.15 and testReturnObject.data.id is undefined. The data object is a stringified JSON. The same with the getId function using testReturnObject.run(): the result is a string. Happy to help! |
@lelesrc |
UpdateAlthough we have tried with different versions of Appsmith, the cloud-services remains to the latest version. And that’s where the problem was hiding. Next course of actionWe will be creating 3 PRs.
|
## Description TL;DR This commit fixes unexpected stringified JSON in the following plugins - REST API Plugin - GraphQL plugin The detailed analysis can be found in the comment section of the issue itself (#22450) Slack Conversations - [1](https://theappsmith.slack.com/archives/C0341RERY4R/p1681123872154409) - [2](https://theappsmith.slack.com/archives/CGBPVEJ5C/p1681726446635249) > Add a TL;DR when description is extra long (helps content team) Fixes #22450 Media ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
## Description TL;DR This commit fixes unexpected stringified JSON in the following plugins - REST API Plugin - GraphQL plugin The detailed analysis can be found in the comment section of the issue itself (#22450) Slack Conversations - [1](https://theappsmith.slack.com/archives/C0341RERY4R/p1681123872154409) - [2](https://theappsmith.slack.com/archives/CGBPVEJ5C/p1681726446635249) > Add a TL;DR when description is extra long (helps content team) Fixes #22450 Media ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
## Description TL;DR This commit fixes unexpected stringified JSON in the following plugins - REST API Plugin - GraphQL plugin The detailed analysis can be found in the comment section of the issue itself (#22450) Slack Conversations - [1](https://theappsmith.slack.com/archives/C0341RERY4R/p1681123872154409) - [2](https://theappsmith.slack.com/archives/CGBPVEJ5C/p1681726446635249) > Add a TL;DR when description is extra long (helps content team) Fixes #22450 Media ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
UpdateThe fix is now available on Appsmith cloud i.e. app.appsmith.com with Appsmith Version: v1.9.17. cc: @lelesrc |
Closing this out as per discussions. |
Is there an existing issue for this?
Description
Slack Conversation
Error in JSON format returned by users' API server gets stringified by Appsmith server.
Steps To Reproduce
Api1
https://mock.codes/500
in the URI{{Api1.data.description}}
in theText
fieldYou will notice that the evaluated value doesn't show anything because the response is coming as stringified.
Public Sample App
No response
Environment
Production
Issue video log
No response
Version
Cloud / Self Hosted
The text was updated successfully, but these errors were encountered: