pub fn sanitize_connection_string(conn_str: &str) -> StringExpand description
Removes sensitive information (passwords) from a connection string before it is logged.
store_addrs entries can be a PostgreSQL DSN (a postgres(ql):// URL or a
libpq keyword string), a MySQL/etcd URL, or an etcd host list.
The function fails closed: it never returns a URI-shaped input verbatim. In order:
- PostgreSQL DSNs are parsed with
tokio_postgres::Config— the backend’s own parser — and logged via itsDebug, which redacts the password. This matches the grammar exactly (multi-host URIs,\-escapes, any Unicode whitespace, percent-encoded query keys,&/;/://inside values). - Any other URL is redacted with the
urlcrate. - A URI-shaped input that neither parser accepted (e.g. a malformed multi-host Postgres URI, with or without leading whitespace) is redacted in full — credentials in an unparsable authority or query cannot be split out reliably, so the whole string is replaced rather than reparsed.
- Anything else is treated as a keyword string and best-effort redacted.