appwrite: 🐛 Bug Report: Adding enums with length greater than before results in server error

👟 Reproduction steps

Make a collection in a database for and an Enum Attribute paymentStatus Attrib has

  • 3 Enums: Success - Pending - Failure
  • if I edit this attribute and add Intiated this won’t work, because mariaDB has already taken the highest length of Pending, Success and Failure that is 7

👍 Expected behavior

It should just add new data to the enum without an error

👎 Actual Behavior

This is the error it throws in the Appwrite container logs image

This is the error it throws on Client or on server while trying to add Initiated Enum to the attribute field

image

🎲 Appwrite version

Version 1.3.x

💻 Operating system

Linux

🧱 Your Environment

No response

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

  • I checked and didn’t find similar issue

🏢 Have you read the Code of Conduct?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 25 (8 by maintainers)

Most upvoted comments

i can reproduce. Set varchar(50) (or text…) on enum fields ?

@christyjacob4 Thank you for the reply 😃

Yes, I’ve updated as described by the Appwrite documentation, including executing the migration command and verifying that it did finish.

I didn’t update from the previous version but instead skipped a few smaller updates. However I didn’t skip any minor or major versions, so according to the docs this shouldn’t cause any problems.

Is there anything that I could provide that would help to debug this issue?

I updated my Appwrite instance after having this bug today. Even though your changelog states the issue was fixed with version 1.4.13, I still encounter the same issue. I updated the instance normally and did the migration as described in your documentation. Is there anything else I can do on my end?

I’m having this issue as well, on AppWrite 1.4.1

To be clear, the error doesn’t occur when adding a new Enum to the attribute list. The error occurs when adding a document that uses that Enum.

It seems to work like this:

  1. Attribute is added to collection with a set of options: ex. “Four”, “Five”, “Six”
  2. Appwrite creates a column in the table under _#database#collection## with the longest length in the list, “Four” and “Five” are 4 characters, so we get a 4 character column.
  3. We go add an extra option “Seven”
  4. Appwrite accepts this, but makes no changes to the column in the table. At this point, Appwrite should update _#database#collection## setting the width of the column to 5 characters, but doesn’t.
  5. We add a document to the collection, including our new Enum option “Seven”. This causes Appwrite to throw the error.

Example error produced in appwrite error log for version 1.4.1:

[Error] Timestamp: 2023-10-22T06:38:10+00:00
[Error] Method: POST
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents
[Error] Type: PDOException
[Error] Message: Data too long for column 'status' at row 1
[Error] File: @swoole-src/library/core/Database/PDOStatementProxy.php
[Error] Line: 62

Note the most useful part of this error, the message; “Data too long for column ‘status’ at row 1”, isn’t returned in the API response, thought the stack trace is. I’m not including any error message related to where a code resolution would be, as the code that needs resolved is the part that handles updating of the attribute, and doesn’t throw any error.

Hey everyone, I’ve been trying to reproduce this bug on the console and CLI (v1.3.8), and even on the master branch of the repo, with 0 success. So it looks like this issue is fixed?

It’s because of this code

Possibilities

  1. Fixed size (255 for ex)
  2. Round up to 25 more
  3. Add size input on form to let user decide

Quick fix : Edit field property on mariaDB to change max size

Ideal solution is to update table when update enum attribute, to let it transparent to user