
now it got completed quickly

and got same error

{
"success": false,
"error": {
"code": 400,
"type": "attribute_not_available",
"response": {
"message": "Attribute not available: timestamp",
"code": 400,
"type": "attribute_not_available",
"version": "0.10.45"
}
}
}

not sure how to fix this now.

Yes, There is one more thing to add

One sec I'll update the snippet

okay, thank you

Done

okay, let me try again.

finally, it worked! 🎉

just putting my code here for future reference for other devs:


thank you so much both of you for helping me!!

[Solved] Cloud function Fails to create index

one last question,

what will happen when the attribute stays in a processing
state for minutes?

because there is a function timeout of 15 seconds. so will it fail? or should I use self-hosted instead of cloud?

you should make sure to handle that case. at the moment, on cloud, it can take up to 30 minutes when there is a db backup going on

I'm no sure about your use case.
But, you can:
- **Scheduler **approach - Use cronjobs for the indexing part, and, let that part being executed once every
N
minutes, that will work best with what Steven said about timing. - Event-driven approach - create a function that will trigger on the
databases.*.collections.*.attributes.*.create
event, then add an index to that attribute.- With this approach you'll get it even before the attribute is ready, so make sure to check it.
- All-or-nothing approach - Do like the function you have here, and in cast ir fails just delete everything you've created.
It probably won't be good to extended the timeout time for a function like so.
If you need right now - as thing will, from what I've understand, be different when cloud's out of beta - then you can go the self-hosted route.

my use case is for one-one chat conversation.

every time when new user creates a chat, my cloud function executes and creates collection, storage bucket and all other stuff in the function code.

including index

so i can't make user wait for long. or else chat will not work

I see, that's keep thing the same. You just need to choose the right approach to handle the holding time.
The other approach could be by using teams, roles and leverage Appwrite permission with few collections to start with, check these:

thanks for this, I have already a working chat system, just needed to fix that cloud function error. let me show you some screenshots, it's in Flutter and Appwrite.
I haven't used the Team feature yet, so I'm just giving permission to only conversation participants to access the conversation colletion.
Recommended threads
- Permissions for bulk operation
Hi team, I have a question: “In the databases.createDocuments bulk API, can I set document-level permissions? If yes, how exactly should I include the permissio...
- Help understanding what "upgrade" and "m...
Hello, I'm currently running appwrite with k8s (well, a dirty "hack" of converting each container to a deployment). And I have some trouble understand what "upg...
- hi I’m reaching out with an urgent req...
hi I’m reaching out with an urgent request regarding my account. My organization’s access has been restricted due to a $90 unpaid invoice, and I’m currently s...
