sdk-for-python icon indicating copy to clipboard operation
sdk-for-python copied to clipboard

🐛 Bug Report: remove default with required is true (Enums and maybe others)

Open Sau1707 opened this issue 7 months ago • 1 comments

👟 Reproduction steps

from appwrite.client import Client
from appwrite.services.databases import Database

client.set_endpoint("<Endpoint>")
client.set_project("<Project>") 
client.set_key('standard_xxx')  

client = Client()

db = Databases(client)
db.update_enum_attribute(
    database_id=database_id,
    collection_id=collection_id,
    key=key,
    elements=elements,
    required=True,
    default=None
)

👍 Expected behavior

It should allow to update the field without a default parameter when required is set to true.

👎 Actual Behavior

Editor complains about the type: Argument of type "None" cannot be assigned to parameter "default" of type "str" in function "update_enum_attribute"

Execution error: Error: Param "default" is not optional.

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Windows

🧱 Your Environment

Python 3.13.1 (venv) appwrite-11.0.0

👀 Have you spent some time to check if this issue has been raised before?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Sau1707 avatar Jun 14 '25 14:06 Sau1707

In the website, the request is send with the parameters:

{
      default: null
      elements: [""]
      required: true
}

While in the python sdk the default: null is missing. This is because in appwrite/client.py at line 81.

params = {k: v for k, v in params.items() if v is not None}  # Remove None values from params dictionary

Remove the default value when set to None.

Sau1707 avatar Jun 14 '25 14:06 Sau1707

@Sau1707 Thanks for pointing this issue out. Its been noted and a fix will be released soon 🙏

ChiragAgg5k avatar Jun 30 '25 09:06 ChiragAgg5k