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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vaultwarden silently falls back to SQLite if DATABASE_URL is invalid #2835

Closed
netthier opened this issue Oct 17, 2022 · 5 comments
Closed

Vaultwarden silently falls back to SQLite if DATABASE_URL is invalid #2835

netthier opened this issue Oct 17, 2022 · 5 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@netthier
Copy link

Subject of the issue

When an invalid DATABASE_URL is specified, e.g. with a typo such as postgreql://user:pwd@host or with quotes like "postgresql://user:pwd@host", Vaultwarden silently falls back to using the SQLite database without logging any errors or warnings.

Deployment environment

Used image is vaultwarden/server:1.26.0

Steps to reproduce

I started vaultwarden via a docker-compose file with the DATABASE_URL variable set

Expected behaviour

If an invalid DATABASE_URL is specified, Vaultwarden should either log an error or a warning along the lines of "Failed to parse DATABASE_URL, falling back to SQLite"

Actual behaviour

Vaultwarden starts regularly and runs migrations against an SQLite database.

@tessus
Copy link
Contributor

tessus commented Oct 17, 2022

I've noticed the same beavior and IMO it should not fall back to sqlite, but abend with an error message.

@BlackDex
Copy link
Collaborator

Where did you configured this? Docker compose file? Custom export? Systemd file. And could you give an example? Without the actual password etc if course.

@netthier
Copy link
Author

Where did you configured this? Docker compose file? Custom export? Systemd file. And could you give an example? Without the actual password etc if course.

As mentioned in the issue, I specified this in my docker-compose file. The issue also contains examples without actual passwords.
I noticed this issue after accidentally specifying the URL like this:

environment:
  - DATABASE_URL="postgresql://user:pwd@host/vaultwarden"

Specifying it as "DATABASE_URL=postgresql://user:pwd@host/vaultwarden" instead worked.
Before opening this issue I further investigated by intentionally introducing a typo in the working variant, and removing a letter from the protocol, ending up with postgreql://etc, which led to the same issue.

@BlackDex
Copy link
Collaborator

Thanks for the extra info.
The thing is that the quotes are an issue with compose, but not with export or a .env loaded by Vaultwarden it self.

But, it indeed should not continue if there is a faulty setting.
The only setting which could be seen as faulty but still should fall back is an empty string, since that indicates a default.

Thanks for the report.

@BlackDex BlackDex added bug Something isn't working enhancement New feature or request labels Oct 17, 2022
stefan0xC added a commit to stefan0xC/vaultwarden that referenced this issue Oct 27, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit.

this should fix issues like dani-garcia#2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
stefan0xC added a commit to stefan0xC/vaultwarden that referenced this issue Oct 27, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit.

this should fix issues like dani-garcia#2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
stefan0xC added a commit to stefan0xC/vaultwarden that referenced this issue Oct 28, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit.

this should fix issues like dani-garcia#2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
stefan0xC added a commit to stefan0xC/vaultwarden that referenced this issue Nov 11, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit.

this should fix issues like dani-garcia#2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
stefan0xC added a commit to stefan0xC/vaultwarden that referenced this issue Nov 22, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit if it does not.

this should fix issues like dani-garcia#2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
stefan0xC added a commit to stefan0xC/vaultwarden that referenced this issue Nov 22, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit if it does not.

this should fix issues like dani-garcia#2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
stefan0xC added a commit to stefan0xC/vaultwarden that referenced this issue Nov 28, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit if it does not.

this should fix issues like dani-garcia#2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
dani-garcia pushed a commit that referenced this issue Dec 1, 2022
instead of creating the parent folders to a sqlite database
vaultwarden should just exit if it does not.

this should fix issues like #2835 when a wrongly configured
`DATABASE_URL` falls back to using sqlite
@BlackDex
Copy link
Collaborator

BlackDex commented Dec 8, 2022

Should be resolved via #2873 already.

@BlackDex BlackDex closed this as completed Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants