appwrite: 🐛 Bug Report: Invalid Queries Causes 500 Error

👟 Reproduction steps

  1. Make an API call with an invalid queries like: GET v1/users?queries=100.

👍 Expected behavior

400 error response with some helpful message

👎 Actual Behavior

500 server error

appwrite logs:

appwrite                        | Warning: foreach() argument must be of type array|object, string given in /usr/src/code/src/Appwrite/Utopia/Database/Validator/Queries.php on line 56
appwrite                        | [Error] Timestamp: 2022-09-23T16:09:33+00:00
appwrite                        | [Error] Method: GET
appwrite                        | [Error] URL: /v1/users
appwrite                        | [Error] Type: TypeError
appwrite                        | [Error] Message: {closure}(): Argument #1 ($queries) must be of type array, string given, called in /usr/src/code/vendor/utopia-php/framework/src/App.php on line 558
appwrite                        | [Error] File: /usr/src/code/app/controllers/api/users.php
appwrite                        | [Error] Line: 366

It would be good to check $value before iterating over it:

https://github.com/appwrite/appwrite/blob/384543c553f01ac889790042693136b4bfbd80f7/src/Appwrite/Utopia/Database/Validator/Queries.php#L56

We should also have test cases to cover this scenario:

https://github.com/appwrite/appwrite/blob/384543c553f01ac889790042693136b4bfbd80f7/tests/unit/Utopia/Database/Validator/QueriesTest.php#L54

🎲 Appwrite version

Version 1.0.x

💻 Operating system

Linux

🧱 Your Environment

Appwrite Version 1.0.1

👀 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 2 years ago
  • Reactions: 2
  • Comments: 42 (16 by maintainers)

Most upvoted comments

If it gets unassigned, can i take it up?

The issues are assigned first come, first serve. If the other contributors become idle, it will go to you!

can i work on this ? @Haimantika

Hi @0xchikku assigning the issue to you now. Please remember to share update every 3 days

@Haimantika, could you please assign this issue to me

Hi, are you still interested to contribute?

Yes, I am

Hi, we assign first-come first-serve basis.

@KKVANONYMOUS, thanks for the update!

@himanshu007-creator, I’ll assign the issue to you. Thanks!