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

🐛 Bug Report: Error updating properties of required attributes using dart-sdk

Open ShivanshuKGupta opened this issue 1 year ago • 0 comments

👟 Reproduction steps

  1. Create a new collection with a string attribute with required = true and give a max size of 255.
  2. Try to update only the max size of this attribute using dart-sdk.

Sample code:

import 'package:dart_appwrite/dart_appwrite.dart';
import 'package:televolution_sync/appwrite/appwrite.dart';

void main() async {
  final client = Client()
    ..setEndpoint(constants.endpoint)
    ..setProject(constants.projectId)
    ..setKey(constants.apiKey)
    ..setSelfSigned(status: true);

  final databases = Databases(client);

  final nameAttribute = await databases.getAttribute(
    databaseId: 'TEST',
    collectionId: 'TESTCOLLECTION',
    key: 'name',
  );

  print('nameAttribute = $nameAttribute');
  // Output of above line:
  // nameAttribute = {key: name, type: string, status: available, error: , required: true, array: false, size: 255, default: null}

  /// Now, I will try to update the size to 1000 (previously 255)
  final updatedAttribute = await databases.updateStringAttribute(
    databaseId: 'TEST',
    collectionId: 'TESTCOLLECTION',
    key: 'name',
    size: 1000,
    xdefault: null, // I also tried these values here: ("", "no name", null), but I get errors on all of them.
    xrequired: true,
  );

  print('updatedAttribute = $updatedAttribute'); // Never reached this line
}

👍 Expected behavior

The attribute should be updated with the new size.

👎 Actual Behavior

Get an error related to default value:

  1. If you try to keep null as the default value: Image

  2. If you try to give some other default value (which shouldn't be the case, because the attribute is required by nature): Image

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Something else

🧱 Your Environment

Appwrite Cloud Version: 1.6.0 Dart Version: 3.1.5 Dart SDK Version: dart_appwrite 12.1.0

The code doesn't work, neither from my local machine nor from an appwrite function.

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

ShivanshuKGupta avatar Oct 16 '24 13:10 ShivanshuKGupta