Skip to content

fix(bigquery): prevent NullPointerException in OTel tracing when JobId is null#13301

Open
keshavdandeva wants to merge 3 commits into
mainfrom
kd/prevent-npe-in-otel
Open

fix(bigquery): prevent NullPointerException in OTel tracing when JobId is null#13301
keshavdandeva wants to merge 3 commits into
mainfrom
kd/prevent-npe-in-otel

Conversation

@keshavdandeva
Copy link
Copy Markdown
Contributor

b/517929704

This PR addresses a NullPointerException that occurs in the BigQuery client library when OpenTelemetry tracing is enabled and operations are performed on jobs that do not have a client-assigned JobId at the start of the call.

A notable case where this happens is during dry-run queries (often used to determine statement type or fetch statistics) where JobInfo.getJobId() returns null. The OTel instrumentation was attempting to extract attributes from the JobId without checking for nullability.

Changes:

  • Added null checks before calling JobId.getOtelAttributes() in BigQueryImpl.create(JobInfo) (line 455).
  • Added null checks before calling JobId.getOtelAttributes() in BigQueryImpl.getQueryResults(JobId) (line 2128).
  • These changes align with the safe-check pattern already implemented in BigQueryImpl.queryWithTimeout (line 2075).

@keshavdandeva keshavdandeva requested review from a team as code owners May 29, 2026 16:59
@keshavdandeva keshavdandeva requested review from logachev and lqiu96 May 29, 2026 16:59
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 null checks for job IDs before retrieving OpenTelemetry attributes in BigQueryImpl.java. The reviewer recommended using Attributes.empty() instead of passing null to setAllAttributes to prevent potential NullPointerExceptions in certain OpenTelemetry implementations or mock tracers.

@lqiu96
Copy link
Copy Markdown
Member

lqiu96 commented May 29, 2026

Thanks for the info and the context. I don't have any concerns with this

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