Skip to content

fix(datastream): prevent NullPointerException in ExtractGcsFile - #4290

Open
gauravjain6633 wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
gauravjain6633:fix-datastream-npe
Open

gauravjain6633 wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
gauravjain6633:fix-datastream-npe

Conversation

@gauravjain6633

@gauravjain6633 gauravjain6633 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This pull request improves the robustness of the DataStream source connector by adding defensive checks for incoming Pub/Sub messages. By validating the presence of essential GCS notification attributes, the pipeline now avoids runtime errors when encountering malformed messages and provides better visibility through logging.

Highlights
NullPointerException Prevention: Added validation checks to ensure that Pub/Sub message attributes are present before processing, preventing potential NullPointerExceptions.
Improved Error Handling: Implemented logging to warn when Pub/Sub messages are missing required GCS notification attributes, allowing the pipeline to skip malformed messages gracefully.
Expanded Test Coverage: Added unit tests to verify that the ExtractGcsFile function correctly ignores messages with missing attributes or non-finalize event types.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the robustness of the DataStream source connector by adding defensive checks for incoming Pub/Sub messages. By validating the presence of essential GCS notification attributes, the pipeline now avoids runtime errors when encountering malformed messages and provides better visibility through logging.

Highlights

  • NullPointerException Prevention: Added validation checks to ensure that Pub/Sub message attributes are present before processing, preventing potential NullPointerExceptions.
  • Improved Error Handling: Implemented logging to warn when Pub/Sub messages are missing required GCS notification attributes, allowing the pipeline to skip malformed messages gracefully.
  • Expanded Test Coverage: Added unit tests to verify that the ExtractGcsFile function correctly ignores messages with missing attributes or non-finalize event types.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@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 improves the robustness of the ExtractGcsFile processing in DataStreamIO.java by adding null-safety checks and logging for missing GCS notification attributes. It also adds unit tests in DataStreamIOTest.java to cover these scenarios. However, the test file is missing several required imports for the newly added tests and the TestPipeline rule, which will lead to compilation failures.

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.33%. Comparing base (4364622) to head (2c916df).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...d/teleport/v2/datastream/sources/DataStreamIO.java 50.00% 0 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (50.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff              @@
##               main    #4290       +/-   ##
=============================================
+ Coverage     34.34%   56.33%   +21.98%     
- Complexity      524     7849     +7325     
=============================================
  Files           216     1154      +938     
  Lines         13274    73223    +59949     
  Branches       1322     8586     +7264     
=============================================
+ Hits           4559    41247    +36688     
- Misses         8345    29185    +20840     
- Partials        370     2791     +2421     
Components Coverage Δ
spanner-templates 84.48% <ø> (∅)
spanner-import-export 68.86% <ø> (∅)
spanner-live-forward-migration 88.99% <ø> (∅)
spanner-live-reverse-replication 80.87% <ø> (∅)
spanner-bulk-migration 89.00% <ø> (∅)
gcs-spanner-dv 88.11% <ø> (∅)
Files with missing lines Coverage Δ
...d/teleport/v2/datastream/sources/DataStreamIO.java 48.27% <50.00%> (ø)

... and 962 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants