-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Accidental delete of all rows in react-admin (using ra-data-hasura data connector) #2741
Comments
I just cloned the ra-data-hasura code from the master branch and linked it as a local package. Edit: Found it! The source code (content of /src) is identical for both, but for some weird reason there's a difference in the transpiled code. In the source code (src/index.js) you have the following lines:
But the transpiled code for the npm package (lib/ra-data-hasura.js) has:
It should be '$in': params.ids There must have been a mix-up in the build process before publishing the package. |
Regarding your first comment where: {} Will evaluate to where = true |
Yes exactly, this results in a full-table delete without any conditions.
results in
|
Fixed in 0a64ef9 |
…2100, hasura#2741, hasura#2771) (hasura#2727) * filter for count in GET_LIST and GET_MANY_REFERENCE * update deps, add httpClient argument, release new version
…chema` PR-URL: hasura/graphql-engine-mono#2743 GitOrigin-RevId: c1e56bf
I just tried out react-admin with Hasura and used the ra-data-hasura data connector for that.
When selecting a single entry in my "Jobs" resource and then clicking "Delete" it will ultimately remove all rows in my jobs table.
How to reproduce?
This is the request generated by ra-data-hasura:
POST https://<HASURA_APP>.herokuapp.com/v1/query
Body:
{ "args": { "$set": {}, "returning": [ "id" ], "table": { "name": "jobs", "schema": "public" }, "where": { "id": {} } }, "type": "delete" }
Please notice the missing id argument in the where condition.
Expected Behavior
There's something wrong (maybe on my side) that no id is passed to the where condition of the delete query, but in any case this shouldn't lead to Hasura deleting all rows. Instead it should return an error that the id argument is missing and not do anything.
Maybe also having a setting to disallow bulk deletes/updates of all rows without any where conditions would be a good idea. As a reference please check this section about blocking Full-Table operations for the PostgREST project:
http://postgrest.org/en/v5.0/admin.html
The text was updated successfully, but these errors were encountered: