Skip to content

Commit c131d1e

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 c131d1e

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

pg_lake_engine/src/pgduck/client.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,24 @@ GetPGDuckConnection(void)
139139

140140
if (PQstatus(connection) != CONNECTION_OK)
141141
{
142-
char PG_USED_FOR_ASSERTS_ONLY *errorMessage = pstrdup(PQerrorMessage(connection));
142+
char *errorMessage = pstrdup(PQerrorMessage(connection));
143143

144144
PQfinish(connection);
145145

146-
#ifdef USE_ASSERT_CHECKING
147-
ereport(ERROR,
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.
150+
*/
151+
ereport(LOG_SERVER_ONLY,
148152
(errmsg("could not start query engine: %s", errorMessage),
149153
errdetail("connection string: %s", PgduckServerConninfo)));
154+
155+
#ifdef USE_ASSERT_CHECKING
156+
ereport(ERROR, (errmsg("could not start query engine: %s", errorMessage)));
150157
#else
151158
/* hide internals from users */
152-
ereport(ERROR,
153-
(errmsg("could not start query engine"),
154-
errdetail("connection string: %s", PgduckServerConninfo)));
159+
ereport(ERROR, (errmsg("could not start query engine")));
155160
#endif
156161
}
157162

0 commit comments

Comments
 (0)