Skip to content

fix(bigquery-jdbc): mask property values in URL logging and add allowUrlLogPath option - #15167

Open
Neenu1995 wants to merge 5 commits into
fix/bq-jdbc-log-handler-lifecyclefrom
fix/bq-jdbc-url-log-masking
Open

Neenu1995 wants to merge 5 commits into
fix/bq-jdbc-log-handler-lifecyclefrom
fix/bq-jdbc-url-log-masking

Conversation

@Neenu1995

Copy link
Copy Markdown
Contributor

Summary

PR 4 of 6 in the diagnostic logging stack (b/584840083, part 1 of 2; stacked on fix/bq-jdbc-log-handler-lifecycle). Applies allowlist property masking during URL assembly, binds reentrant MDC context from the start of BigQueryDriver.connect, and adds -Dcom.google.cloud.bigquery.jdbc.allowUrlLogPath.

Environment Variables & System Properties

  • Added System Property: -Dcom.google.cloud.bigquery.jdbc.allowUrlLogPath=<true|false> (default: true). When set to false, LogPath supplied via the JDBC URL or Properties is ignored (logging a WARNING without failing connect()) and implicit fallback to the current working directory is disabled so local log files are written only when BIGQUERY_JDBC_LOG_PATH is configured in the environment. Documented in README.MD and docs/USER_GUIDE.md.
  • New Environment Variables: None added in this PR.

Design Decisions

  • Allowlist-based maskPropertyValue across URL & connection logging: Centralizes property redaction on BigQueryConnection.SAFE_TO_LOG_PROPERTIES (excluding BYOID_CredentialSource) and reuses BigQueryConnection.maskPropertyValue inside BigQueryJdbcUrlUtility.appendPropertiesToURL via lazy Supplier<String> logging at FINEST, ensuring unrecognized or credential-bearing Properties entries are masked consistently.
  • JVM-level allowUrlLogPath switch (default true): Multi-connection server deployments that accept caller-supplied JDBC URLs need a JVM-wide way to keep filesystem log output controlled strictly by host environment variables (BIGQUERY_JDBC_LOG_PATH), while standalone tools and existing integrations retain full backward compatibility by default (true) and connections never fail when URL LogPath is ignored.
  • Reentrant BigQueryJdbcMdc & early connectionId allocation: Allocates connectionId at the top of BigQueryDriver.connect so URL parsing and connection setup logs carry the connection ID, while saving and restoring any outer MDC context on MdcCloseable.close() for nested connection creation.

…UrlLogPath option

PR 4 of 6 in the diagnostic logging series (b/584840083, part 1 of 2).

Applies BigQueryConnection.SAFE_TO_LOG_PROPERTIES allowlist masking in BigQueryJdbcUrlUtility.appendPropertiesToURL, binds reentrant BigQueryJdbcMdc context at the start of BigQueryDriver.connect with failure cleanup, and adds -Dcom.google.cloud.bigquery.jdbc.allowUrlLogPath.
@Neenu1995
Neenu1995 requested review from a team as code owners November 23, 2026 19:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new system property, com.google.cloud.bigquery.jdbc.allowUrlLogPath, to control whether the LogPath parameter supplied via the JDBC URL or connection properties is honored. It also refactors logging to mask sensitive properties, introduces connection-specific MDC logging with nested context support, and adds comprehensive unit tests. The code review feedback highlights several key areas for improvement: addressing a race condition in BigQueryJdbcRootLogger where closing the global static fileHandler can disrupt logging for other active connections, performing case-insensitive lookups for safe logging properties to prevent unnecessary masking, wrapping System.getProperty in a try-catch block to handle potential SecurityExceptions under a Security Manager, and sorting properties before appending them to the URL to ensure deterministic output.

@Neenu1995
Neenu1995 added this pull request to stack #15170 November 23, 2026 20:21
@Neenu1995 Neenu1995 changed the title [WIP] fix(bigquery-jdbc): mask property values in URL logging and add allowUrlLogPath option fix(bigquery-jdbc): mask property values in URL logging and add allowUrlLogPath option Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant