Skip to content
Back

Unkown Attribute Error

  • 0
  • Databases
Stargate
4 May, 2025, 07:07

I have a python server function setting up a database that follows the following flow: 1. create collection, 2. create attributes, 3. create document. I am getting a "Unkown attribute "APP_USER_ID" ". Here is a sample of my code ``` def init(self, subscription: str): super().init("Info") self.subscription = subscription self.key = "APP_USER_ID"

TypeScript
def create_attribute(self):
    self.db.databases.create_string_attribute(
        database_id=self.uid,
        collection_id=self.collection,
        key=self.key,
        size=300,
        required=True,
    )

def create_document(self):
    self.db.databases.create_document(
        database_id=self.uid,
        collection_id=self.collection,
        document_id=ID.unique(),
        data={ self.key:self.subscription }
    )

def create(self):
    super().create()
    self.create_attribute()
    self.create_document()
TypeScript
The part that throws me, is that the error is not always in the same spot.  Without making any changes the code above can complete just fine.  But I always get the same error (just on a different collection).  My only guess is that the requests are async, in which case the document could attempt to be created just before the attribute is.  This doesn't make any sense though as (from what I can tell) appwrite (and the libraries it uses) is synchronous and each function is blocking.  In which case I am at a loss.

Thanks in advance for any help.
TL;DR
Issue: Unknown attribute error "APP_USER_ID" is appearing inconsistently during the database setup process. Solution: The error might be caused by possible asynchronous requests within the code despite the perception that the functions are synchronous. To fix this, ensure that the attribute is created before attempting to create the document by restructuring the code flow or introducing waiting mechanisms to synchronize the operations.
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