Comments (10)
Ok, I have reproduced this bug. It's a bit nuanced. There is no error from Appwrite because it turns your string into an int but returns a string in the create event response. If you then fetch the documents it will return the new entry with the correct type.
My thoughts are that Appwrite should either:
- Throw an error when you pass anything that is not an int
- Or it should return the create response with the attribute as an int after it parses it to int type in the background
from appwrite.
Ok, I have reproduced this bug. It's a bit nuanced. There is no error from Appwrite because it turns your string into an int but returns a string in the create event response. If you then fetch the documents it will return the new entry with the correct type.
My thoughts are that Appwrite should either:
- Throw an error when you pass anything that is not an int
- Or it should return the create response with the attribute as an int after it parses it to int type in the background
Yes,
Because the "Create event" returns the data before parsing it, it will cause issues if I expect an int from request.body
in the function and get a string instead.
I think the most effective solution is the first one you suggested:
- Throw an error when you pass anything that is not an int
from appwrite.
@stnguyen90 This is intentional, it would just add unnecessary friction to throw an error if the string is a valid integer. The event should definitely fire with with an int though.
from appwrite.
It seems you have passed the amount a string value so it inferred it as a string, did you explicitly set the amount as int in appwrite? or set the type of amount to be an int type somewhere else in the code?
from appwrite.
It seems you have passed the amount a string value so it inferred it as a string, did you explicitly set the amount as int in appwrite? or set the type of amount to be an int type somewhere else in the code?
The AMOUNT attribute is an int in appwrite, it should never accept Numbers as strings, ever.
But from what I see it accepts numbers as Strings then maybe it got parsed in the process in appwrite before it reaches the database but__ the function event caught it before it got parsed, and this is the issue with that, if a programming error happens in the front end and the programmer pass the value as a string, appwrite should throw an error,
If I'm expecting to get an int value from the function event but got String instead that will cause problems.
Why parse the value and then write it to the database when you can make it only acceptΒ intΒ simply?
from appwrite.
It seems you have passed the amount a string value so it inferred it as a string, did you explicitly set the amount as int in appwrite? or set the type of amount to be an int type somewhere else in the code?
try the Reproduction steps...
from appwrite.
Throw an error when you pass anything that is not an int
Yes, I agree we should throw an error if the incorrect type is passed.
Would either of you be interested in working on this?
from appwrite.
I'd love to give it a shot
from appwrite.
@stnguyen90 This is intentional, it would just add unnecessary friction to throw an error if the string is a valid integer. The event should definitely fire with with an int though.
The it should return the create response with the attribute as an int after it parses it to int type in the background..
from appwrite.
This is intentional, it would just add unnecessary friction to throw an error if the string is a valid integer. The event should definitely fire with with an int though.
@abnegate, so where and how would be the best place to convert the attribute such that we don't miss anything and we handle all attribute? The Structure validation should only be for validation and shouldn't mutate the data, right? Would we need to update encode()?
from appwrite.
Related Issues (20)
- π Enhancement: Please add support for Matrix Real Time Communication
- π Bug Report: Execution timed out when I upload a file to storage through a function HOT 1
- π Bug Report: Getting 502 Bad gateway always while trying to create file/upload in storage using appwrite cloud in React project HOT 1
- π Bug Report: network error on uploading file larger than 3 mb HOT 2
- π Enhancement: Improving Sessions-Display in the Dashboard
- π Bug Report: trying to connect GitHub to functions
- π Bug Report: APP_STORAGE_PREVIEW_LIMIT is not respected
- π Enhancement: Please add third-part mirrors support for all Funtion builds
- π Bug Report: Support ticket not working on appwrite HOT 1
- π Bug Report: Function timed out during cold start HOT 1
- π Bug Report: Unexpected Behavior in Appwrite Bucket Permissions HOT 1
- π Enhancement: Support Node 22 HOT 1
- π Bug Report: Disallow personal data not working when trying to reset password through my flutter app
- π Bug Report: Session Alert template broken for all languages except English HOT 1
- π Enhancement: Option to configure response codes for unauthorized access
- π Enhancement: Allow data only push notification on Appwrite Massaging
- π Bug Report: C# Upload from .net Core 8 - webapi error when file is too big. HOT 1
- π Bug Report: Bun Runtime causes Crashes, Cold Start Failures, and Executor Issues
- π Enhancement: Update GeoLite2 lite database periodically (CI)
- π Bug Report: Session Secret not Passed without API key HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from appwrite.