
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
- ❗[Help] Function stuck in "waiting" stat...
Hi Appwrite team 👋 I'm trying to contribute to Appwrite and followed the official setup instructions from the CONTRIBUTING.md guide to run the platform locall...
- Unable to create push providers - FCM or...
Currently unable to create a push provider for FCM or APNS.... https://github.com/appwrite/console/issues/2045 When uploading a file... FCM = Valid file retu...
- Stuck in "deleting"
my parent element have relationship that doesnt exist and its stuck in "deleting", i cant delete it gives me error: Collection with the requested ID could not b...
