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

Fix for ids not being escaped in paths in the Simple Rest Data Provider #10206

Conversation

ckhsponge
Copy link
Contributor

@ckhsponge ckhsponge commented Sep 16, 2024

Problem

Records may have ids with characters that break the Simple REST Data Provider paths if not escaped.
For example, a record with id "Post#123" has a getOne path of '/posts/Post#123' which is not desired.
IDs like this can occur when using single table inheritance with DynamoDB or with other document data stores.

Solution

The solution is to escape IDs in paths for getOne, update, updateMany, delete and deleteMany. An example path with escaped id is '/posts/Post%23123'.

Closes #10207

How To Test

Perform getOne, update, updateMany, delete and deleteMany with records that have escape-requiring ids e.g. 'Post#123'.

Additional Checks

  • [ x ] The PR targets master for a bugfix, or next for a feature
  • [ x ] The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • [ x ] The documentation is up to date

Also, please make sure to read the contributing guidelines.

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! I found a few problems to be fixed before we can merge it.

packages/ra-data-simple-rest/src/index.ts Outdated Show resolved Hide resolved
packages/ra-data-simple-rest/src/index.spec.ts Outdated Show resolved Hide resolved
packages/ra-data-simple-rest/src/index.spec.ts Outdated Show resolved Hide resolved
packages/ra-data-simple-rest/src/index.spec.ts Outdated Show resolved Hide resolved
@ckhsponge
Copy link
Contributor Author

Thanks for reviewing my PR!

I think an existing deleteMany test had an incorrect input which made me think objects were allowed as inputs there and for updateMany. I fixed that test and mine and removed that check from the data provider.

@fzaninotto fzaninotto merged commit 9052a88 into marmelab:master Sep 23, 2024
13 checks passed
@fzaninotto
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ids not being escaped in paths in the Simple Rest Data Provider
2 participants