Back

Error deleting a file after adding delete permissions

  • 0
  • Self Hosted
  • General
  • Web
  • Storage
kathelia.dokgu
27 Aug, 2023, 01:43

I'm unable to delete a file in my bucket after updating my team-based permissions.

  1. Create a team and give it create, read, and update permissions to a bucket
  2. Upload multiple files by using storage.createFile()
  3. Delete one of those files by using storage.deleteFile() - you should get an error here about not having the permission to delete the file
  4. Add the delete permission to the team you created on step 1
  5. Try deleting the file again and you'll still get an error

I keep getting an error when I attempt to delete a file after giving the team I belong to delete permissions.

If I delete the file from the console this is what I get:

TypeScript
{
    "message": "Server Error",
    "code": 500,
    "type": "general_server_error",
    "version": "1.3.8"
}

If I attempt to open the file, this is what I get:

TypeScript
{
    "message": "File not found in \/storage\/uploads\/app-<ID>\/<ID>\/<ID>.jpg",
    "code": 404,
    "type": "storage_file_not_found",
    "version":"1.3.8"
}

NOTE: This only happens to the file I had the error on when I didn't have the delete permission. I was able to successfully delete the other files that I didn't try to delete before adding the delete permission.

TL;DR
The user is experiencing an error when trying to delete a file after granting the necessary permissions. The error message states that the user is not authorized to perform the action. The user uploaded multiple files using the client SDK and is unable to delete one of them even after adding the delete permission to their team. They receive a 500 error when attempting to delete the file from the console. Opening the file also yields a 404 error. However, this issue only occurs with the specific file that the user initially had an error with before granting the delete permission. A potential solution or workaround is not mentioned in the thread.
Drake
27 Aug, 2023, 02:05

When you got the 500 error, what was the docker logs for the appwrite container related to that 500 error

Drake
27 Aug, 2023, 02:06

Did you create and delete the files using a client SDK?

Drake
27 Aug, 2023, 02:08

Was file security enabled?

kathelia.dokgu
27 Aug, 2023, 02:15

I'm done working on the project today so I'll take a look at the logs tomorrow.

kathelia.dokgu
27 Aug, 2023, 02:15

Yes it was created using a client SDK (web). The first delete attempt (when I got the error) was done via the client SDK as well. However, after I added the delete permission to the team I belong to, I only tried deleting the file from the console.

kathelia.dokgu
27 Aug, 2023, 02:15

File security is disabled and I'm doing bucket-level permissions.

kathelia.dokgu
27 Aug, 2023, 02:25
TypeScript
[Error] Timestamp: 2023-08-27T01:25:41+00:00
[Error] Method: DELETE
[Error] URL: /v1/storage/buckets/:bucketId/files/:fileId
[Error] Type: Appwrite\Extend\Exception
[Error] Message: The current user is not authorized to perform the requested action.
[Error] File: /usr/src/code/app/controllers/api/storage.php
[Error] Line: 1426
[Error] Timestamp: 2023-08-27T01:26:40+00:00
[Error] Method: DELETE
[Error] URL: /v1/storage/buckets/:bucketId/files/:fileId
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Failed to delete file from device
[Error] File: /usr/src/code/app/controllers/api/storage.php
[Error] Line: 1436

The first DELETE was when I attempted to delete the file using the client SDK (web) - this was back when I didn't have the delete permission granted to the team I belong to.

The second DELETE was after I added the permission to the team I belong to - but I only tried to delete the file from the console at this point.

Drake
28 Aug, 2023, 15:10

@joeyouss would you please try to reproduce this?

joeyouss
28 Aug, 2023, 17:58
Drake
28 Aug, 2023, 18:00

Fyi, what could be happening is the actual file gets deleted from the device, but maybe there's a bug with the internal document for the file and that fails to get deleted. Then, the file ends up in an inconsistent state where the actual file is gone, but Appwrite's metadata for the file is still there

joeyouss
28 Aug, 2023, 18:00

Yeah I commented the same thing but this shouldn't be happening

Drake
28 Aug, 2023, 18:02

Well see once you try to reproduce it. We can debug if we can reliably reproduce the problem

Drake
1 Sep, 2023, 03:39

Looks like there was a permission bug. Hopefully this fix will be fixed in 1.4.2: https://github.com/appwrite/appwrite/pull/6102

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more