PostgresDSN with prefix falls back to non-prefixed env vars by accident
Created by: slimsag
An input to PostgresDSN
without a database name, like:
(note how there is no /databasename
at the end) will, instead of having an empty ""
database name have the value of PGDATABASE
- NOT CODEINSIGHTS_PGDATABASE
.
This seems to be an affect of having an empty string for the database, and the pgx library falling back to PGDATABASE
in that case.
This affects all prefixed DSNs, e.g. CODEINTEL_PGDATASOURCE
is also affected and other variants like specifying CODEINTEL_PGUSER
but not CODEINTEL_PGDATABASE
will cause it to fallback to unprefixed PGDATABASE
.
Discovered via https://github.com/sourcegraph/sourcegraph/pull/17738
Workaround: make sure the DSN has all options present, e.g.: