AppwriteException: general_argument_invalid, Param "default" is not optional. (400)
TL;DR
Error occurs when attempting to update a string attribute's default value in Dart SDK due to the value being required, not allowing it to be set to null. To solve this, the `xdefault` parameter should be handled differently when `attributeA.required` is true to avoid setting it to null, which results in an error.cc: @D5 We are using dart-sdk for performing this sync
Here is a code snippet for the same:
TypeScript
await dest.databases.updateStringAttribute(
databaseId: databaseId,
collectionId: collectionId,
key: attributeA.key,
size: attributeA.size!,
xrequired: attributeA.required,
xdefault:
attributeA.required ? null : (attributeA.defaultValue ?? ''),
);
if I write the xdefault part like this:
TypeScript
xdefault: attributeA.defaultValue ?? '',
I get this error:
AppwriteException: attribute_default_unsupported, Cannot set default value for required attribute (400)
Hmm I think it can't be nul as it needs to be true or false?
Recommended threads
- Custom domain not pointing to the most r...
My custom domain is pointing to an old deployment version, but it shows it's active on the appwrite console.
- Server Error when importing to tables
Same .csv file worked yesterday, Please fix it asap
- Backup does not restore
I need to urgently restore a backup but nothing is happening when trying to restore!