Skip to content

feat: add X-Goog-Request-Reason header support#205

Open
pareshgoogle wants to merge 1 commit into
looker-open-source:mainfrom
pareshgoogle:feat/request-reason-header
Open

feat: add X-Goog-Request-Reason header support#205
pareshgoogle wants to merge 1 commit into
looker-open-source:mainfrom
pareshgoogle:feat/request-reason-header

Conversation

@pareshgoogle
Copy link
Copy Markdown
Contributor

@pareshgoogle pareshgoogle commented Apr 17, 2026

Description

This PR adds support for passing the X-Goog-Request-Reason HTTP header in BigQuery API requests made by the bqjdbc driver. A new JDBC connection property requestReason is introduced to allow users to specify this reason.

Changes

  • BQConnection.java: Updated to parse the requestReason property from the connection URL or properties.
  • Oauth2Bigquery.java: Propagated the requestReason through the authorization flow and injected it as the X-Goog-Request-Reason header in HttpRequestTimeoutInitializer.
  • Oauth2Bigquery.java: Maintained BigQueryRequestUserAgentInitializer for backward compatibility with existing Looker infrastructure.
  • JdbcUrlTest.java: Added a unit test urlWithRequestReasonSendsHeader to verify that the header is correctly added to requests.

Verification

  • Unit tests have been added and formatting issues fixed.
  • Note: Local tests failed with InaccessibleObjectException due to running on Java 25 (the project targets Java 8-15, and CI uses Java 1.8). The tests are expected to pass in the CI environment.

@pareshgoogle pareshgoogle marked this pull request as draft April 17, 2026 09:26
Copy link
Copy Markdown
Contributor

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

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 adds support for a requestReason property to the BigQuery JDBC driver. The property is extracted from connection settings and passed through the authorization process to be included as an X-Goog-Request-Reason header in HTTP requests. The HttpRequestTimeoutInitializer was updated to handle this header along with the User-Agent. A new test case confirms the header is correctly sent. I have no feedback to provide.

@pareshgoogle pareshgoogle marked this pull request as ready for review April 17, 2026 09:31
@pareshgoogle pareshgoogle marked this pull request as draft April 17, 2026 09:32
Copy link
Copy Markdown
Contributor Author

@pareshgoogle pareshgoogle left a comment

Choose a reason for hiding this comment

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

This looks good to me as I created the PR

@rhgoogle
Copy link
Copy Markdown
Contributor

The change looks good. We might need to fix the Build / test CI as part of this PR.

@rhgoogle rhgoogle marked this pull request as ready for review April 20, 2026 21:53
@rhgoogle rhgoogle force-pushed the feat/request-reason-header branch from c106318 to 467149e Compare April 21, 2026 15:34
Copy link
Copy Markdown
Contributor

@rhgoogle rhgoogle left a comment

Choose a reason for hiding this comment

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

Changes LGTM! Thanks.

@rhgoogle
Copy link
Copy Markdown
Contributor

CI failed because this PR is from an external fork. I created an internal mirrow PR #207 to move forward.

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.

2 participants