Back

Server Error 500: If you try to set Double field from given default value to Null

  • 0
  • Databases
  • Self Hosted
Vedsaga
20 Jul, 2023, 13:16

db logs doesn't seems would be that helpful

TL;DR
The user encountered a server error (500) when trying to set a Double field from its default value to null. They provided a JSON code snippet and mentioned trying to debug the issue using the network tab and console. They suspected that the browser may be causing the issue. They also mentioned creating the attribute for testing with the default value of 0 and specified the min and max values. They suggested trying to replicate the issue using the Appwrite API and provided a link. The user noticed that the default value changed from 0.0 (double) to 0 (integer) and shared an error message indicating that the default value does not
Binyamin
20 Jul, 2023, 13:18

In these lines

TypeScript
[Error] Method: PATCH
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/attributes/float/:key
[Error] Type: Exception
[Error] Message: Default value 0 does not match given type double
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php
[Error] Line: 956
Vedsaga
20 Jul, 2023, 13:19

yaa, for some reason

Vedsaga
20 Jul, 2023, 13:19

should not have happen

Binyamin
20 Jul, 2023, 13:20

That's for sure

Binyamin
20 Jul, 2023, 13:21

So you've created a double with default value as 0 right?

Vedsaga
20 Jul, 2023, 13:21

yap

Vedsaga
20 Jul, 2023, 13:21

and then tried to change that to null via console

Binyamin
20 Jul, 2023, 13:22

Can you try to change it to 0.0

Binyamin
20 Jul, 2023, 13:22

Instead of 0?

Vedsaga
20 Jul, 2023, 13:22

umm, let me try

Vedsaga
20 Jul, 2023, 13:24

same error,

TypeScript
[Error] Timestamp: 2023-07-20T13:23:21+00:00
[Error] Method: PATCH
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/attributes/float/:key
[Error] Type: Exception
[Error] Message: Default value 0 does not match given type double
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php
[Error] Line: 956
Binyamin
20 Jul, 2023, 13:25

You can see here, this is how Appwrite verifying the default value for the type

Binyamin
20 Jul, 2023, 13:26

So some how the value changed to 0 from the double one 0.0

Binyamin
20 Jul, 2023, 13:27

Maybe it worth trying to do so with the Appwrite API https://appwrite.io/docs/server/databases?sdk=nodejs-default#databasesCreateFloatAttribute

And try to put 0.0 there

Vedsaga
20 Jul, 2023, 13:28
TypeScript
"document":{"$id":"1_3_testing","key":"testing","databaseInternalId":"1","databaseId":"64b403562105501ffe56","collectionInternalId":"3","collectionId":"64b8c9d71b86ae78319a","type":"double","status":"processing","size":0,"required":false,"signed":true,"default":0,"array":false,"format":"floatRange","formatOptions":{"min":0,"max":1},"filters":[],"options":[],"$collection":"attributes","$createdAt":"2023-07-20T13:23:13.540+00:00","$updatedAt":"2023-07-20T13:23:13.540+00:00","$internalId":"44","min":0,"max":1},

this is the attribute I created for testing

Binyamin
20 Jul, 2023, 13:29

So the default is 0 the integer

Vedsaga
20 Jul, 2023, 13:29

I did put, min:0 and max:1

Vedsaga
20 Jul, 2023, 13:29

wired it shouldn't as I did pass, 0.0 as defult

Binyamin
20 Jul, 2023, 13:30

I think maybe the browser doing that

Vedsaga
20 Jul, 2023, 13:31

let me try to check once more, and have netwrok tab

Vedsaga
20 Jul, 2023, 13:32

in console

Vedsaga
20 Jul, 2023, 13:32
TypeScript
{"key":"test","required":false,"min":0,"max":1,"default":0,"array":false}

network tab

Binyamin
20 Jul, 2023, 13:37

Yep,

Binyamin
20 Jul, 2023, 13:37

So this will cause the problem

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more