Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Database usage screen shows 500 error when _APP_USAGE_STATS is disabled #4960

Closed
2 tasks done
gigili opened this issue Jan 6, 2023 · 18 comments 路 Fixed by #5246 or #7087
Closed
2 tasks done
Assignees
Labels
bug Something isn't working product / console Console, UI and UX issues

Comments

@gigili
Copy link

gigili commented Jan 6, 2023

馃憻 Reproduction steps

  • Select a project
  • Click on the Databases in the sidebar
  • Click on the Usage tab or try to go into a specific database and/or collection and clicking on the same tab

馃憤 Expected behavior

To be able to see the database usage information

馃憥 Actual Behavior

I just upgraded from version 1.1.2 to 1.2.0 and when opening the database usage pages:

  • https://my-domain.com/console/project-[project-id]/databases/usage
  • https://my-domain.com/console/project-[project-id]/databases/database-[database-id]/usage
  • https://my-domain.com/console/project-[project-id]/databases/database-[database-id]/collection-[collection-id]/usage

They all show a 500 internal error page and looking at the appwrite container logs I can see this:

[Error] Method: GET
[Error] URL: /v1/databases/:databaseId/usage
[Error] Type: TypeError
[Error] Message: Appwrite\Utopia\Response::dynamic(): Argument #1 ($document) must be of type Utopia\Database\Document, array given, called in /usr/src/code/app/controllers/api/databases.php on line 2673
[Error] File: /usr/src/code/src/Appwrite/Utopia/Response.php
[Error] Line: 411
[Error] Timestamp: 2023-01-06T11:02:27+00:00
[Error] Method: GET
[Error] URL: /v1/databases/usage
[Error] Type: TypeError
[Error] Message: Appwrite\Utopia\Response::dynamic(): Argument #1 ($document) must be of type Utopia\Database\Document, array given, called in /usr/src/code/app/controllers/api/databases.php on line 2564
[Error] File: /usr/src/code/src/Appwrite/Utopia/Response.php
[Error] Line: 411
[Error] Timestamp: 2023-01-06T11:02:58+00:00
[Error] Method: GET
[Error] URL: /v1/databases/:databaseId/usage
[Error] Type: TypeError
[Error] Message: Appwrite\Utopia\Response::dynamic(): Argument #1 ($document) must be of type Utopia\Database\Document, array given, called in /usr/src/code/app/controllers/api/databases.php on line 2673
[Error] File: /usr/src/code/src/Appwrite/Utopia/Response.php
[Error] Line: 411

Other pages such as Collections and/or Settings open just fine.

appwrite-db-usage-error

馃幉 Appwrite version

Version 1.2.x

馃捇 Operating system

Linux

馃П Your Environment

  • Docker version 20.10.22, build 3a2c30b
  • docker-compose version 1.25.0, build unknown
  • Linux 5.4.0-135-generic
  • Ubuntu 20.04.5 LTS

馃憖 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?

@gigili gigili added the bug Something isn't working label Jan 6, 2023
@stnguyen90 stnguyen90 self-assigned this Jan 6, 2023
@stnguyen90
Copy link
Contributor

@gigili thanks for raising this issue! 馃檹馃徏 You said you just upgraded. Did you run the migrate command after upgrading?

@gigili
Copy link
Author

gigili commented Jan 6, 2023

Hey @stnguyen90, yeah I was following the official upgrade guide and did run the migration command after upgrading all the containers to 1.2 version.

@gigili
Copy link
Author

gigili commented Jan 10, 2023

Hey, I did some checking around my appwrite instance and noticed this issue is not only linked to that database screens but every service that has the Usage tab in it shows the same error page and the same thing in the logs.

I've also tried to deploy a separate clean instance of appwrite and it has the same problem, so it doesn't seem to be related to just upgraded version.

@stnguyen90
Copy link
Contributor

yeah I was following the official upgrade guide and did run the migration command after upgrading all the containers to 1.2 version.

Any errors? What's in your appwrite folder now?

Hey, I did some checking around my appwrite instance and noticed this issue is not only linked to that database screens but every service that has the Usage tab in it shows the same error page and the same thing in the logs.

It really looks like there was a migration step missing so anything related to usage will error out.

I've also tried to deploy a separate clean instance of appwrite and it has the same problem, so it doesn't seem to be related to just upgraded version.

Clean instance? so did you wipe the old volumes and install again or did you use a different server?

@gigili
Copy link
Author

gigili commented Jan 10, 2023

Any errors? What's in your appwrite folder now?

Everything looked normal (I say looked, because I deleted everything and tried from scratch to install appwrite). During the upgrade process there were no errors and everything went smoothly.

Clean instance? so did you wipe the old volumes and install again or did you use a different server?

Yeah I wiped everything (containers, volumes, networks, images) and did a brand new install of appwrite from scratch on that same server. The only thing I didn't do from scratch was the .env file (I used one left behind by migration) and the docker-compose.yml file as well. But I could try using "clean" versions of those as well if you think it might make a difference.

I can share the yml and .env file if that would help out.

@stnguyen90
Copy link
Contributor

Yeah I wiped everything

@gigili how did you wipe everything exactly?

@gigili
Copy link
Author

gigili commented Jan 10, 2023

I've used Portainer and it's UI to delete the containers, than I removed all the leftover volumes and than the networks, than run the docker compose up -d --remove-orphans to create everything

@stnguyen90
Copy link
Contributor

I can share the yml and .env file if that would help out.

@gigili, sure, you can share the files with me and I can try to spin them up to see if I see the error.

@gigili
Copy link
Author

gigili commented Jan 10, 2023

I've attached the files below, I had to strip out all the sensitive info from the .env file and replace it with demo and example, if you need more info or access to the instance it self, we can move this conversation over to discord and add conclusions here when done.

appwrite.zip

@stnguyen90 stnguyen90 assigned ArmanNik and stnguyen90 and unassigned stnguyen90 and ArmanNik Jan 10, 2023
@stnguyen90
Copy link
Contributor

@gigili, thanks! Would you please try updating _APP_USAGE_STATS to enabled?

@stnguyen90 stnguyen90 changed the title 馃悰 Bug Report: Database usage screen shows 500 error 馃悰 Bug Report: Database usage screen shows 500 error when _APP_USAGE_STATS is disabled Jan 11, 2023
@gigili
Copy link
Author

gigili commented Jan 11, 2023

Hi, after setting _APP_USAGE_STATS to enabled (by mistake set it to just enable first and it didn't work), now the usage screen shows normally. Do you want me to close this issue ?

@stnguyen90
Copy link
Contributor

Hi, after setting _APP_USAGE_STATS to enabled (by mistake set it to just enable first and it didn't work), now the usage screen shows normally. Do you want me to close this issue ?

Nah, the Console should handle this gracefully and show no stats or something rather than throwing a 500 error

@stnguyen90 stnguyen90 removed their assignment Jan 11, 2023
@stnguyen90 stnguyen90 added the product / console Console, UI and UX issues label Jan 11, 2023
@singhbhaskar
Copy link
Contributor

Hi @stnguyen90 ,
Can I work on this bug?
For the following endpoints:

https://my-domain.com/console/project-[project-id]/databases/usage
https://my-domain.com/console/project-[project-id]/databases/database-[database-id]/usage
https://my-domain.com/console/project-[project-id]/databases/database-[database-id]/collection-[collection-id]/usage

We can check if _APP_USAGE_STATS is enabled or not. If it's not enabled we can change the response to not send 500 and instead send 501 directing the user to enable _APP_USAGE_STATS

@stnguyen90
Copy link
Contributor

@singhbhaskar, returning 501 sounds like a good idea. Please make sure to add a new error with a description like:

'description' => 'Phone provider is not configured. Please check the _APP_SMS_PROVIDER environment variable of your Appwrite server.',

Please, share what happens in the console after this change.

@singhbhaskar
Copy link
Contributor

Thanks @stnguyen90. Sure will do that.

@singhbhaskar
Copy link
Contributor

singhbhaskar commented Mar 17, 2023

Hey @stnguyen90 ,
To fix this bug I need to make change to both backend and console front end. So for front end do I need to raise a new PR for appwrite/console repo?

@singhbhaskar
Copy link
Contributor

Hey @stnguyen90 ,
Raised the PR for this kindly review it.

Thanks
Bhaskar

@stnguyen90 stnguyen90 added this to the 1.3.0 milestone Mar 30, 2023
@stnguyen90 stnguyen90 linked a pull request Apr 25, 2023 that will close this issue
2 tasks
@stnguyen90 stnguyen90 modified the milestones: 1.3.0, 1.3.3, 1.3.4 Apr 25, 2023
@stnguyen90 stnguyen90 reopened this Nov 6, 2023
@stnguyen90
Copy link
Contributor

Looks like we have a regression in 1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / console Console, UI and UX issues
Projects
None yet
4 participants