Back

Creating a file with id unique() breaks storage

  • 0
  • Cloud
Nevus
16 May, 2023, 14:32

I saw in https://github.com/appwrite/sdk-for-python/blob/master/appwrite/id.py that the unique method returns the string "unique()". So made a REST API request to the cloud version of appwrite using fileId = "unique()". Now, I cant delete the file or open it.

TL;DR
Issue: Creating a file with the fileId set to "unique()" breaks storage in Appwrite. File cannot be accessed, updated, or deleted. Potential solution: The use of "unique()" as the fileId is causing this issue. Instead, generate a unique random id for the fileId parameter when creating a file. Creating an issue on the Appwrite GitHub repository could help in preventing the usage of "unique()" as the fileId in the future. SDK Used: Go SDK Further information: The code does not match the behavior of other SDKs. It seems that passing "unique()" as the value of the x-appwrite-id header causes problems
Nevus
16 May, 2023, 14:34
Binyamin
16 May, 2023, 14:39

What are you doing before you get this error? Can you share screenshot of that?

Nevus
16 May, 2023, 14:41

uploading file to the createFile endpoint using unofficial go sdk

Nevus
16 May, 2023, 14:42

I set the fileId to unique() but its being set to literal unique() instead of a random uid.

Binyamin
16 May, 2023, 14:44

Okay,

Binyamin
16 May, 2023, 14:44

What SDK you're using?

Binyamin
16 May, 2023, 14:51

That's look fine

Binyamin
16 May, 2023, 14:51

But how you get this one?

Nevus
16 May, 2023, 14:52
Nevus
16 May, 2023, 14:52

Then that broke appwrite.

Binyamin
16 May, 2023, 14:53

Okay? So you have file with string id equals to unique()?

Nevus
16 May, 2023, 14:53

Yes.

Nevus
16 May, 2023, 14:54

It should have generated a unique random id but it didn't. Since, every other SDK uses the same process I am missing something. Just dont know what.

Binyamin
16 May, 2023, 14:57

Okay, But this error is in the console, right? Is it show when you load the list?

Nevus
16 May, 2023, 15:00

ahh I think we are going in circles. Here's what happened.

  1. I created a file using CreateFile endpoint. The endpoint has a fileId parameter. The value for that was set to unique()
  2. The file upload succeded. The return value of json has id: unique()
  3. The file appears in console. However, it cannot be accessed, updated or deleted. This happens for all platforms: console, SDK and REST. I dont know GraphQL but there's no reason to suspect otherwise.
Nevus
16 May, 2023, 15:01

Yes, I can see the file but that's it. There's no way to interact with the file whatsoever except deleting the bucket itself.

Binyamin
16 May, 2023, 15:10

Got you, okay.

Because you're using the cloud you can't access the DB directly and change the file ID manually. so you'll need to wait to an answer for that from a core <:appwrite:637383039499894787> user.

As for the understanding of the unique string you can see here https://discord.com/channels/564160730845151244/1106476734704009256/1106490852316041257

So I was double checking to see if your ID is exactly unique() as this shouldn't pass this line. https://github.com/appwrite/appwrite/blob/master/app/controllers/api/storage.php#LL439C20-L439C38

Last, the Go SDK has support of the ID function https://github.com/Suven-p/sdk-for-go/blob/master/id/id.go#L8

Drake
16 May, 2023, 17:28

The code doesn't quite match up with how our other SDKs work. It looks like unique() is being passed in the x-appwrite-id header which breaks things...Appwrite should probably block that from happening, so it would be good if you created an issue so we make sure this doesn't happen

Nevus
16 May, 2023, 18:48

The only way to resolve this delete the bucket?

Drake
16 May, 2023, 19:24

ya i think so

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