Skip to content
This repository was archived by the owner on Oct 25, 2022. It is now read-only.

DSN is handled incorrectly #8

Open
karlism opened this issue May 17, 2021 · 1 comment
Open

DSN is handled incorrectly #8

karlism opened this issue May 17, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@karlism
Copy link

karlism commented May 17, 2021

Hello,

There is an issue with DSN string handling, let me show you an example:

$ ./bareos_exporter -dsn=postgres://bareos:bareospw@localhost/bareos
panic: missing "=" after "bareos:bareospw@localhost/bareos" in connection info string"

goroutine 1 [running]:
main.main()
	/github/workspace/main.go:52 +0x46d

It is perfectly valid URL, but bareos_exporter expects it to have = symbol in it. If I add additional connection parameters, it is working fine (the system is not running PostgreSQL locally, so connection refused is fine in this case):

$ ./bareos_exporter -dsn=postgres://bareos:bareospw@localhost/bareos?readOnly=true
panic: dial tcp [::1]:5432: connect: connection refused
@vierbergenlars vierbergenlars added the bug Something isn't working label Jul 10, 2021
@vierbergenlars
Copy link
Owner

Sorry, it looks like I missed your issue for some time.

This looks like a small issue indeed.
To determine which database driver to use, I split the string by ://, and only pass the righthand side to the database driver.

libpq on the other hand expects the full DSN to be passed, or a list of option=value, separated by spaces, which I guess where the weird error message comes from.

The second DSN is probably also not handled correctly, but you have an option named bareos:bareospw@localhost/bareos?readOnly with value true (which is then just ignored by the driver, and it defaults to connect to localhost.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants