Fix #1854: Preserve @querystring order by making sort_keys optional#1985
Fix #1854: Preserve @querystring order by making sort_keys optional#1985hasansyed107 wants to merge 9 commits intoplone:mainfrom
Conversation
|
Syed Ahmed mubasiruddin the email address in your commit does not match an email in your GitHub account. Thus it is impossible to determine whether you have signed the Plone Contributor Agreement, which is required to merge this pull request. Learn about the Plone Contributor Agreement: https://plone.org/foundation/contributors-agreement If you have sent in your Plone Contributor Agreement, and received and accepted an invitation to join the Plone GitHub organization, then you might need to either add the email address on your Agreement to your GitHub account or change the email address in your commits. If you need to do the latter, then you should squash the commits with your matching email and push them. Add more emails to your GitHub account: Change the email address in your commits: |
|
@hasansyed107 thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment: To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
8248303 to
febe325
Compare
|
@hasansyed107 you need to sign the Plone Contributor Agreement to merge this pull request. Learn about the Plone Contributor Agreement: https://plone.org/foundation/contributors-agreement If you have already signed the agreement, please allow a week for your agreement to be processed. If after a week you have not received an invitation, then please contact agreements@plone.org. |
news/1854.bugfix
Outdated
| @@ -0,0 +1 @@ | |||
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. | |||
There was a problem hiding this comment.
Add markup and give yourself credit.
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. | |
| Allow services to opt-out of JSON `sort_keys` to preserve `@querystring` order. @hasansyed107 |
There was a problem hiding this comment.
Still hasn't been updated. Don't know why it was resolved.
|
needs some love and a description. |
|
@hasansyed107 you need to sign the Plone Contributor Agreement to merge this pull request. Learn about the Plone Contributor Agreement: https://plone.org/foundation/contributors-agreement If you have already signed the agreement, please allow a week for your agreement to be processed. If after a week you have not received an invitation, then please contact agreements@plone.org. |
davisagli
left a comment
There was a problem hiding this comment.
This is not a good solution to the problem.
JSON does not guarantee that the order of object properties will be preserved.
When the order is important, we should serialize a list instead.
This means we have to first update Volto to accept either the existing object or a list. Then we can update the format in plone.restapi and make a breaking release.
3195b28 to
dfaf1c1
Compare
|
@hasansyed107 you need to sign the Plone Contributor Agreement to merge this pull request. Learn about the Plone Contributor Agreement: https://plone.org/foundation/contributors-agreement If you have already signed the agreement, please allow a week for your agreement to be processed. If after a week you have not received an invitation, then please contact agreements@plone.org. |
|
Thank you for the clarification, @davisagli. I agree that a list-based structure is the correct approach when order must be preserved. To confirm the expected structure: should the current mapping be converted into a list of objects with the key represented as an I’ll start reviewing the relevant Volto components to plan backward compatibility. |
|
Hi @davisagli and @jensens, I have updated the @querystring service to return ordered lists for indexes and sortable_indexes as requested. To ensure backward compatibility, I have opened the companion Volto PR here: https://github.com/plone/volto/pull/7917 @jenkins-plone-org please run jobs |
news/1854.bugfix
Outdated
| @@ -0,0 +1 @@ | |||
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. | |||
There was a problem hiding this comment.
Still hasn't been updated. Don't know why it was resolved.
davisagli
left a comment
There was a problem hiding this comment.
There are tests which are failing because of the change and need to be updated. And a few other details.
| sort_keys = getattr(self, "sort_keys", True) | ||
| return json.dumps( | ||
| content, indent=2, sort_keys=True, separators=(", ", ": ") | ||
| content, indent=2, sort_keys=sort_keys, separators=(", ", ": ") |
|
Hi @davisagli and @stevepiercy, I have completed the requested updates for this PR. It is now aligned with the corresponding frontend changes in Volto. Summary of updates: Implementation: Restored the original Service class docstrings and ensured the sort_keys opt-out logic is clean and non-breaking. Documentation: Updated the OpenAPI specification by running make docs to reflect the change to a list-based structure in the @querystring endpoint. News Fragment: Added a proper news fragment (news/1854.feature) with the correct credits and description. Tests: Updated the Python backend tests to match the new response format. Linked Volto PR: plone/volto#7917 @jenkins-plone-org please run jobs |
There was a problem hiding this comment.
Remove this file. It shouldn't be committed.
| @@ -0,0 +1 @@ | |||
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. @hasansyed107 | |||
There was a problem hiding this comment.
Still hasn't been resolved correctly with MyST markup.
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. @hasansyed107 | |
| Allow services to opt-out of JSON `sort_keys` to preserve `@querystring` order. @hasansyed107 |
There was a problem hiding this comment.
More importantly, this only describes the part of the pull request that is no longer relevant.
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. @hasansyed107 | |
| The `@querystring` service now returns index as a list rather than an object, to preserve the order. @hasansyed107 |
And, it's a breaking change, so the file extension needs to be .breaking instead of .feature
| @@ -0,0 +1 @@ | |||
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. @hasansyed107 | |||
There was a problem hiding this comment.
More importantly, this only describes the part of the pull request that is no longer relevant.
| Allow services to opt-out of JSON sort_keys to preserve @querystring order. @hasansyed107 | |
| The `@querystring` service now returns index as a list rather than an object, to preserve the order. @hasansyed107 |
And, it's a breaking change, so the file extension needs to be .breaking instead of .feature
| sort_keys = getattr(self, "sort_keys", True) | ||
| return json.dumps( | ||
| content, indent=2, sort_keys=True, separators=(", ", ": ") | ||
| content, indent=2, sort_keys=sort_keys, separators=(", ", ": ") |
There was a problem hiding this comment.
This is no longer relevant since we switched to returning a list. Please remove it.
If your pull request closes an open issue, include the exact text below, immediately followed by the issue number. When your pull request gets merged, then that issue will close automatically.
Closes #
📚 Documentation preview 📚: https://plonerestapi--1985.org.readthedocs.build/