elixir-cloud-aai / foca

Opinionated Flask microservice archetype for quick OpenAPI-based microservice development
Apache License 2.0
16 stars 12 forks source link

Cannot use foca with empty database #169

Closed jvkersch closed 1 year ago

jvkersch commented 1 year ago

Calling drop_indexes on a non-existent collection raises a pymongo.errors.OperationFailure. This makes it difficult to use an empty database with a foca app; one needs to manually create the required collections ahead of time.

A fix could be to wrap the call to drop_indexes in a simple try/except.

https://github.com/elixir-cloud-aai/foca/blob/d52e16218e953b34125afb4d541c0e3b47cd4336/foca/database/register_mongodb.py#L57

kushagra189 commented 1 year ago

@jvkersch can you share the configs you were using?

uniqueg commented 1 year ago

I'm also wondering: Isn't .drop_indexes() only called on the collections that are defined in the app config and that are created automatically prior to dropping indexes? So when exactly is this an issue, @jvkersch ?

jvkersch commented 1 year ago

This is embarrassing, but due to my lack of note-taking when the issue first occurred, I am unable to reproduce the issue... I will close this as-is, but I did encounter the issue on a number of occasions, and if I spot it again I will take the time to create a minimal working example. Sorry for wasting your time!

uniqueg commented 1 year ago

No worries at all, @jvkersch. Just re-open it once you can reproduce it. Happy to look at the problem and (hopefully) fix it :)