Skip to content

feat: resolve Neo4j connection settings on workers - #4639

Open
fbiville wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
fbiville:neo4j/connection-read-on-workers
Open

fbiville wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
fbiville:neo4j/connection-read-on-workers

Conversation

@fbiville

Copy link
Copy Markdown
Collaborator

Only pass the connection reference (a GCS URI or a Secret Manager secret id) through the pipeline, and read, validate and map the connection JSON on first use in worker setup.
The launcher no longer needs GCS or Secret Manager access to submit the job, and resolved credentials (passwords/tokens) are no longer captured by serializable suppliers and embedded in the serialized DoFns.

Only pass the connection reference (a GCS URI or a Secret Manager secret id)
through the pipeline, and read, validate and map the connection JSON on first
use in worker setup.
The launcher no longer needs GCS or Secret Manager access to submit the job,
and resolved credentials (passwords/tokens) are no longer captured by
serializable suppliers and embedded in the serialized DoFns.
@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 optimizes Neo4j connection handling by shifting the resolution of connection settings from the job launcher to the worker nodes. By passing only the connection reference (GCS URI or Secret Manager ID) through the pipeline, the changes prevent sensitive credentials from being embedded into serialized Dataflow objects, thereby improving security and reducing the operational requirements for the launcher.

Highlights

  • Lazy connection resolution: Introduced the ConnectionParamsProvider class to resolve Neo4j connection settings on worker nodes instead of the job launcher.
  • Enhanced security: Credentials are no longer embedded in serialized Dataflow pipelines, as they are now fetched directly on the worker, reducing the launcher's required permissions.
  • Refactored ActionContext: Updated ActionContext to a record using a SerializableSupplier for connection parameters, ensuring compatibility with the new lazy resolution approach.
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 refactors the Neo4j connection resolution to occur lazily on the Dataflow workers rather than at pipeline launch time. By introducing ConnectionParamsProvider, a SerializableSupplier, the actual connection credentials are resolved on-demand from Secret Manager or GCS on the worker, preventing sensitive information from being serialized into the pipeline. Additionally, ActionContext has been converted to a record containing this provider. The feedback highlights a potential serialization issue in CypherActionFn where the lambda captures the entire ActionContext object, and suggests using a static helper method to avoid capturing non-serializable fields.

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 22.50000% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.71%. Comparing base (86a5380) to head (da98a07).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...o4j/model/connection/ConnectionParamsProvider.java 0.00% 21 Missing ⚠️
...t/v2/neo4j/transforms/VerifyOrResetDatabaseFn.java 0.00% 3 Missing ⚠️
...eleport/v2/neo4j/templates/GoogleCloudToNeo4j.java 0.00% 2 Missing ⚠️
.../v2/neo4j/templates/Neo4jImportPipelineRunner.java 50.00% 2 Missing ⚠️
...rt/v2/neo4j/actions/function/BigQueryActionFn.java 0.00% 1 Missing ⚠️
...leport/v2/neo4j/actions/function/HttpActionFn.java 0.00% 1 Missing ⚠️
...t/v2/neo4j/transforms/Neo4jRowWriterTransform.java 0.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (22.50%) 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    #4639       +/-   ##
=============================================
+ Coverage     37.79%   59.71%   +21.92%     
- Complexity      521     7924     +7403     
=============================================
  Files           197     1124      +927     
  Lines         12031    72740    +60709     
  Branches       1238     8852     +7614     
=============================================
+ Hits           4547    43438    +38891     
- Misses         7110    26399    +19289     
- Partials        374     2903     +2529     
Components Coverage Δ
spanner-templates 84.02% <ø> (∅)
spanner-import-export 72.72% <ø> (∅)
spanner-live-forward-migration 87.62% <ø> (∅)
spanner-live-reverse-replication 79.92% <ø> (∅)
spanner-bulk-migration 88.27% <ø> (∅)
gcs-spanner-dv 86.54% <ø> (∅)
Files with missing lines Coverage Δ
...d/teleport/v2/neo4j/actions/ActionDoFnFactory.java 37.50% <100.00%> (ø)
...port/v2/neo4j/actions/function/CypherActionFn.java 76.31% <100.00%> (ø)
...oud/teleport/v2/neo4j/model/job/ActionContext.java 100.00% <100.00%> (ø)
...rt/v2/neo4j/actions/function/BigQueryActionFn.java 0.00% <0.00%> (ø)
...leport/v2/neo4j/actions/function/HttpActionFn.java 0.00% <0.00%> (ø)
...t/v2/neo4j/transforms/Neo4jRowWriterTransform.java 84.12% <0.00%> (ø)
...eleport/v2/neo4j/templates/GoogleCloudToNeo4j.java 0.00% <0.00%> (ø)
.../v2/neo4j/templates/Neo4jImportPipelineRunner.java 79.41% <50.00%> (ø)
...t/v2/neo4j/transforms/VerifyOrResetDatabaseFn.java 0.00% <0.00%> (ø)
...o4j/model/connection/ConnectionParamsProvider.java 0.00% <0.00%> (ø)

... and 942 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.

@nord-erik nord-erik 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.

lgtm

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

Labels

2 participants