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

🐛 Bug Report: Updating Attributes with Null Default Fails

Open jaboyc opened this issue 2 years ago • 1 comments

👟 Reproduction steps

When I update an attribute using Databases.update#Attribute and pass in null for xdefault,

👍 Expected behavior

It should set the default value of that attribute to null.

👎 Actual Behavior

It actually throws an exception: AppwriteException: general_argument_invalid, Param "default" is not optional. (400)

I've found that modifying https://github.com/appwrite/sdk-for-dart/blob/master/lib/src/client_mixin.dart#L15 to params.removeWhere((key, value) => value == null && key != 'default'); locally fixes the issue. Looks like the default: null header is being removed before sending the http request, which is causing the exception. This does not seem like a good fix for the issue, but it narrows down where the issue is coming from.

🎲 Appwrite version

Version 0.10.x

💻 Operating system

MacOS

🧱 Your Environment

Using this in a CLI script to automatically update my attributes.

👀 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?

jaboyc avatar Oct 11 '23 12:10 jaboyc

Still relevant. I have the same issue.

estevez-dev avatar Jul 30 '24 08:07 estevez-dev

@estevez-dev @jaboyc sorry for the wait 🙏 team has been extrememly busy with the issues at hand, and will take a look at it

ChiragAgg5k avatar Feb 20 '25 03:02 ChiragAgg5k

@jaboyc did you set the required attribute to true? if so then a default value as null is not allowed:

https://github.com/appwrite/appwrite/blob/7319b12b51dd196711fba05467e5ff6e55c10572/app/controllers/api/databases.php#L2344

ChiragAgg5k avatar Feb 20 '25 10:02 ChiragAgg5k