Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Internal Server Error/500 for API GETs #2

Closed
HalidBalid opened this issue Oct 30, 2019 · 9 comments
Closed

Internal Server Error/500 for API GETs #2

HalidBalid opened this issue Oct 30, 2019 · 9 comments

Comments

@HalidBalid
Copy link

I'm setting up without Docker and think everything is set up correctly, however after starting up the server and web services the page displays:

hyve has encountered an internal error. please check your server.

Along with the console logging these:

GET /api 304 2.101 ms - -
GET /api/info 500 1.257 ms - 31
GET /api/most-used-tags 500 0.542 ms - 31
GET /api/namespaces 500 0.598 ms - 31
GET /api/mime-types 500 0.601 ms - 31

I'm on MacOS 10.13.6 if that has any relevancy. If there's any other details I can provide to help please let me know. And thank you for your hard work!

@imtbl
Copy link
Owner

imtbl commented Oct 30, 2019

Hello,

did you remember to run database migrations before starting the server?

user@local:hyve/services/server$ yarn migrate

You will also need to run a sync before the API will start working:

user@local:hyve/services/sync-<client or server>$ yarn sync

This is also mentioned here: https://github.com/mserajnik/hyve#running-without-docker

The fact that /api doesn't return an error but all the other routes do indicates that hyve has issues accessing the data/tables it's expecting.

If that doesn't fix it, could you please open services/server/app.js and comment out this app.use() block: https://github.com/mserajnik/hyve/blob/66886b53872571833ec2f728a35faa64da0ffa08/services/server/app.js#L97-L110

This should make it so it should display exceptions in the console when you hit the API and encounter an error. Please provide me with that error message then. Sorry, there's currently no configuration to set this.

@HalidBalid
Copy link
Author

Thanks for the quick response. I did run both migration and sync beforehand and they both seemed to successfully complete but there does seem to be something wrong with the database.

SqliteError: no such table: tags
    at Object.getTotalCount (/Users/Anon/hyve/services/server/src/repositories/tags.js:173:23)
    at Object.getTotalTagCount (/Users/Anon/hyve/services/server/src/controllers/tags.js:31:17)
    at /Users/Anon/hyve/services/server/src/routes/info.js:16:40
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at /Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:275:10)
SqliteError: no such table: tags
    at Object.getMostUsed (/Users/Anon/hyve/services/server/src/repositories/tags.js:153:28)
    at Object.getMostUsedTags (/Users/Anon/hyve/services/server/src/controllers/tags.js:25:17)
    at /Users/Anon/hyve/services/server/src/routes/most-used-tags.js:16:31
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at /Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:275:10)
GET /api/namespaces 500 1.889 ms - 1292
SqliteError: no such table: namespaces
    at Object.getNamespaces (/Users/Anon/hyve/services/server/src/repositories/tags.js:168:23)
    at Object.getNamespaces (/Users/Anon/hyve/services/server/src/controllers/tags.js:28:17)
    at /Users/Anon/hyve/services/server/src/routes/namespaces.js:16:42
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at /Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:275:10)
GET /api/mime-types 500 1.132 ms - 1292
SqliteError: no such table: mime_types
    at Object.getMimeTypes (/Users/Anon/hyve/services/server/src/repositories/files.js:796:23)
    at Object.getMimeTypes (/Users/Anon/hyve/services/server/src/controllers/files.js:43:18)
    at /Users/Anon/hyve/services/server/src/routes/mime-types.js:16:42
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/Anon/hyve/services/server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/Anon/hyve/services/server/node_modules/express/lib/router/layer.js:95:5)
    at /Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/Anon/hyve/services/server/node_modules/express/lib/router/index.js:275:10)

@imtbl
Copy link
Owner

imtbl commented Oct 30, 2019

In that case it looks like the sync didn't go through successfully. Are you trying to sync from the client or server database? Could you try running it again and take a look at the output of the sync? It should tell you how many files, tags and namespaces it synced at the end.

@imtbl
Copy link
Owner

imtbl commented Oct 30, 2019

Also make sure hyve server is actually connecting to the correct content.db (the same that you used for the sync).

@HalidBalid
Copy link
Author

I'm trying to sync from the client database. Here's what I get when running yarn sync in sync-client:

yarn run v1.19.1
$ node ./bin/sync
30/10/2019, 12:08:40: Running sync…

Create initial tables (if necessary): 0.002s
Drop zombie tables: 0.000s
Attach hydrus databases: 0.001s
Get services: 0.000s
Get namespaces: 0.008s
Create new tables: 0.004s
Fill new namespaces table: 0.000s
Fill new tags table: 0.004s
Fill new files table: 0.181s
Fill new mappings table: 0.004s
Fill new MIME types table: 0.001s
Update tag counts on new files table: 0.006s
Detach hydrus databases: 0.003s
Replace current tables: 0.035s
Clean up: 0.041s
Total: 0.312s

Namespaces: 0, Tags: 0, Files: 17163, Mappings: 0
✨  Done in 0.45s.

@imtbl
Copy link
Owner

imtbl commented Oct 30, 2019

Hm, that looks correct. At least if you currently don't have any tags? hyve automatically tries to get tags from the first tag service that it finds (so if you are using multiple and have your tags on later services, this wouldn't work right now).

And you are sure the path to the content.db is the same for the sync and the server?

In this case, I'm a bit out of ideas, but would suggest you try to open the content.db with a SQLite client (like https://sqlitebrowser.org/) and see if those tables actually exist.

It should look like this for a working database:

image

@HalidBalid
Copy link
Author

Ah! I had HYVE_CONTENT_DB_PATH set to /Users/Anon/hyve/data/content.db, when I point it to /Users/Anon/hyve/services/server/storage/content.db instead I now no longer get the API errors and see the files but I still don't seem to have tags. I haven't done any tagging myself yet, just from the public tag repository. So if my local tag service is empty that's why I'm not seeing tags in hyve? Should I try migrating tags into my local service?

Again, thanks for the quick responses and your patience.

@imtbl
Copy link
Owner

imtbl commented Oct 30, 2019

Glad you figured it out! Sorry, it's not the easiest to get running since you basically have to duplicate some configuration across the different services. Ideally, I'd want to have one central location for configuration; I might do something about this in the future.

I haven't done any tagging myself yet, just from the public tag repository. So if my local tag service is empty that's why I'm not seeing tags in hyve?

Yes, that's likely the case. I implemented the client sync shortly before the ability to have multiple tag repositories was introduced into hydrus and haven't touched it since then. I guess hydrus might not add those tags you get from the PTR automatically to the local my tags service (which hyve is trying to pull the tags from).

I should also make this configurable, although there's the issue that it's quite a hassle for the user to figure out which service ID is the correct one. Hence the automatic choice for the client sync at the moment; the server sync requires manual configuration, but the IDs are more predictable there and running the server is more technically advanced, which is why I don't feel too bad about having the user configure it manually there.

@HalidBalid
Copy link
Author

No worries! I'll look into tag migration to shove everything into my local tag service (after backing it all up), which would be good enough for me right now. Cheers!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants