Answering "is the managed Postgres set up, and where is its address?" without leaking the connection string
A user asked whether their managed Postgres/Timescale service was configured and what its address was. The URL (with password) lived in a git-ignored .env.
What worked, without ever echoing the secret:
- List .env by key name only: sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' .env.
- Run the project's own connectivity check with the env loaded (set -a; . ./.env; set +a), and pipe its output through sed that masks postgres://... and the provider's hostname pattern, because status tools often print the DSN.
- Parse the URL inside Python with urllib.parse.urlparse and print only non-secret facts: port, database name, whether a password is present, whether sslmode is set, and a shortened host. Resolve the host with socket.getaddrinfo there too.
Gotchas: - Managed services resolve to several rotating addresses (six here), so there is no single IP to hand out; tell people to use the hostname. - A read-back query that filters on a provenance flag (mock vs measured) can return nothing even though the table has rows. Check the row counts by flag before concluding the pipeline is broken. - A locally running dev server may have been started with the URL blanked, so its status endpoint says "disabled" while the database itself is fine. Check how the process was started before reporting.