appwrite / sdk-for-cli

[READ-ONLY] Official Appwrite CLI >_
BSD 3-Clause "New" or "Revised" License
85 stars 28 forks source link

πŸ› Bug Report: appwrite CLI does not properly parse boolean values #22

Closed NeonSpork closed 2 years ago

NeonSpork commented 2 years ago

πŸ‘Ÿ Reproduction steps

(appwrite v0.11.0)

The CLI does not correctly parse boolean values. I believe it passes them as strings without converting and checking if it is a valid boolean value.

In my case, I am attempting to set the emailVerification value of a user manually with the CLI with the following command: appwrite users updateVerification --userId="618d12a8701cd" --emailVerification="true"

(I have tried "true", "True", 'true', 'True', and just about every variant i can think of with the same result.)

πŸ‘ Expected behavior

The CLI should accept and parse the strings true and/or false as boolean values by sanitizing the input and converting the literal strings "true" or "false" to their boolean counterparts, and only give the error message response if any arguement besides true/false is submitted.

πŸ‘Ž Actual Behavior

The command I submitted received the following response:

appwrite users updateVerification --userId="618d12a8701cd" --emailVerification="true"
message : Invalid emailVerification: Value must be a valid boolean
code : 400
version : 0.11.0

🎲 Appwrite version

Appwrite version 0.11.0

πŸ’» Operating system

Linux

🧱 Your Environment

I installed docker following the instructions provided by docker themselves. Appwrite CLI was installed with no problems.

During appwrite init i set the endpoint to my appwrite server hosted on digital ocean (which functions just fine for console and responds to queries appropriately in a web project).

πŸ‘€ Have you spent some time to check if this issue has been raised before?

🏒 Have you read the Code of Conduct?

stnguyen90 commented 2 years ago

How about if you try 1? Also, would you please update the title to include a short summary of the bug?

NeonSpork commented 2 years ago

How about if you try 1? Also, would you please update the title to include a short summary of the bug?

I believe I tried 1, but I'll give that a whirl again!

Also, oops about the title! Should be fixed

aymericfontaine commented 2 years ago

There is still the problem on all boolean parameters.

appwrite database createStringAttribute --collectionId="6212045d91f6a8a03e43" --key="test6" --size=50 --required=1 message : Invalid required: Value must be a valid boolean code : 400 version : 0.12.1

appwrite database createStringAttribute --collectionId="6212045d91f6a8a03e43" --key="test6" --size=50 --required="true" message : Invalid required: Value must be a valid boolean code : 400 version : 0.12.1

appwrite database createStringAttribute --collectionId="6212045d91f6a8a03e43" --key="test6" --size=50 --required=true message : Invalid required: Value must be a valid boolean code : 400 version : 0.12.1

appwrite database createStringAttribute --collectionId="6212045d91f6a8a03e43" --key="test6" --size=50 --required=$vartrue message : Invalid required: Value must be a valid boolean code : 400 version : 0.12.1

christyjacob4 commented 2 years ago

Thank you all for raising this. This shouldn't be a problem anymore with the new CLI

theMeysam commented 2 years ago

in v:0.13.3.303 when I sent http request I see this error yet (I try connect to appwrite via n8n platform): [ { "headers": { "host": "...", "user-agent": "axios/0.21.4", "content-length": "60", "accept": "application/json,text/*;q=0.99", "content-type": "application/json", "x-appwrite-key": "...", "x-appwrite-project": "...", "x-forwarded-for": "...", "x-forwarded-host": "...", "x-forwarded-port": "...", "x-forwarded-proto": "https", "x-forwarded-server": "...", "x-real-ip": "...", "accept-encoding": "gzip" }, "params": { }, "query": { }, "body": { "userId": "633d0d14274r92a93cd4", "emailVerification": "true" } } ]

the report is: { "status": "rejected", "reason": { "message": "400 - {"message":"Invalid emailVerification: Value must be a valid boolean","code":400,"type":"general_argument_invalid","version":"0.13.3"}", "name": "Error", "stack": "Error: Request failed with status code 400 at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15) at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11) at IncomingMessage.emit (node:events:538:35) at endReadableNT (node:internal/streams/readable:1345:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)" } }