Skip to content

Commit 085dd9b

Browse files
pgduck client: log conninfo to server log instead of errdetail
Per review on PR #361: the connection string may include credentials and is an internal detail not appropriate for the client. Emit a separate LOG ereport() with errmsg + errdetail before the user-facing ERROR so administrators can still debug misconfigured servers (issue #293) via the PostgreSQL server log without leaking the conninfo to the client. Signed-off-by: David Christensen <david.christensen@snowflake.com>
1 parent f2d4a28 commit 085dd9b

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

pg_lake_engine/src/pgduck/client.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,22 @@ GetPGDuckConnection(void)
143143

144144
PQfinish(connection);
145145

146-
#ifdef USE_ASSERT_CHECKING
147-
ereport(ERROR,
148-
(errmsg("could not start query engine: %s", errorMessage),
146+
/*
147+
* Log the conninfo to the server log so an administrator can debug
148+
* misconfigured servers (issue #293) without exposing the connection
149+
* string -- which may include credentials -- to the client. We
150+
* intentionally do not include the libpq error message here; it is
151+
* surfaced only in the assertion-enabled ERROR below.
152+
*/
153+
ereport(LOG_SERVER_ONLY,
154+
(errmsg("could not start query engine"),
149155
errdetail("connection string: %s", PgduckServerConninfo)));
156+
157+
#ifdef USE_ASSERT_CHECKING
158+
ereport(ERROR, (errmsg("could not start query engine: %s", errorMessage)));
150159
#else
151160
/* hide internals from users */
152-
ereport(ERROR,
153-
(errmsg("could not start query engine"),
154-
errdetail("connection string: %s", PgduckServerConninfo)));
161+
ereport(ERROR, (errmsg("could not start query engine")));
155162
#endif
156163
}
157164

0 commit comments

Comments
 (0)