Skip to content

feat: introduce validateFields method to SourceConnectionConfig and implement validation for all source configurations#3956

Open
pratickchokhani wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
pratickchokhani:shard-config-validate-fields
Open

feat: introduce validateFields method to SourceConnectionConfig and implement validation for all source configurations#3956
pratickchokhani wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
pratickchokhani:shard-config-validate-fields

Conversation

@pratickchokhani

Copy link
Copy Markdown
Contributor

No description provided.

…mplement validation for all source configurations
@pratickchokhani pratickchokhani force-pushed the shard-config-validate-fields branch from 29e854d to 6c65bdc Compare June 30, 2026 13:07
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jun 30, 2026
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.50000% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.32%. Comparing base (9992792) to head (6c65bdc).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ud/teleport/v2/spanner/migrations/shard/Shard.java 4.76% 10 Missing and 10 partials ⚠️
...igrations/source/config/AstraConnectionConfig.java 11.11% 4 Missing and 4 partials ⚠️
...nner/migrations/source/config/JdbcShardConfig.java 83.33% 0 Missing and 1 partial ⚠️
...r/migrations/source/config/SourceConfigParser.java 88.88% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (37.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    #3956      +/-   ##
============================================
+ Coverage     55.64%   63.32%   +7.67%     
+ Complexity     6731     2455    -4276     
============================================
  Files          1117      528     -589     
  Lines         68313    30636   -37677     
  Branches       7696     3409    -4287     
============================================
- Hits          38012    19399   -18613     
+ Misses        27829    10210   -17619     
+ Partials       2472     1027    -1445     
Components Coverage Δ
spanner-templates 87.90% <37.50%> (+0.25%) ⬆️
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration 89.34% <37.50%> (-0.49%) ⬇️
spanner-live-reverse-replication 82.99% <37.50%> (-0.35%) ⬇️
spanner-bulk-migration 92.29% <37.50%> (-0.29%) ⬇️
gcs-spanner-dv 89.82% <37.50%> (+0.95%) ⬆️
Files with missing lines Coverage Δ
...rt/v2/spanner/migrations/shard/CassandraShard.java 94.28% <ø> (ø)
...tions/source/config/CassandraConnectionConfig.java 100.00% <100.00%> (ø)
...nner/migrations/source/config/JdbcShardConfig.java 90.00% <83.33%> (-10.00%) ⬇️
...r/migrations/source/config/SourceConfigParser.java 88.63% <88.88%> (+1.45%) ⬆️
...igrations/source/config/AstraConnectionConfig.java 69.23% <11.11%> (-30.77%) ⬇️
...ud/teleport/v2/spanner/migrations/shard/Shard.java 67.04% <4.76%> (-19.53%) ⬇️

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

@pratickchokhani pratickchokhani marked this pull request as ready for review July 1, 2026 06:41
@pratickchokhani pratickchokhani requested a review from a team as a code owner July 1, 2026 06:41
@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 introduces a standardized validation mechanism for source connection configurations within the migration framework. By defining a validateFields() method in the SourceConnectionConfig interface and implementing it across all concrete configuration classes, the system now ensures that essential fields are present and valid before proceeding with migration tasks. This change improves system robustness by failing fast when misconfigured source parameters are provided.

Highlights

  • Interface Standardization: Introduced a validateFields() method to the SourceConnectionConfig interface to enforce configuration validation across all source types.
  • Implementation of Validation: Implemented validateFields() in CassandraShard, Shard, AstraConnectionConfig, CassandraConnectionConfig, and JdbcShardConfig to ensure required fields are present.
  • Parser Integration: Updated SourceConfigParser to automatically invoke validateFields() after parsing configurations, ensuring invalid configurations are caught early.
  • Testing: Added unit tests in SourceConfigParserTest to verify that validation logic correctly handles null or empty configuration scenarios.
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.

@pratickchokhani pratickchokhani requested review from bharadwaj-aditya and removed request for darshan-sj and rohitwali July 1, 2026 06:42

@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 validateFields method to the SourceConnectionConfig interface and implements validation logic across various shard and connection configuration classes, including Shard, AstraConnectionConfig, CassandraConnectionConfig, and JdbcShardConfig. It also updates SourceConfigParser to trigger these validations and adds corresponding unit tests. The review feedback points out that because the parser deserializes nulls to empty strings, the validation checks in Shard and AstraConnectionConfig should be updated to check for both null and empty values to prevent invalid configurations from bypassing validation.

throw new IllegalArgumentException("namespace cannot be null");
}
if (secretManagerUri == null) {
throw new IllegalArgumentException("secretManagerUri cannot be null");

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.

secret manager or password can be null. It is possible to pass only one of them.

Can you please verify the logic here ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have integration tests for both secretManagerUri and password. Unless someone sets the value as null manually in the JSON or HOCON string, these values will not be null.

Hence, this check is added.

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.

2 questions

  1. Is there a scenario where someone would want to set these fields explicitly as null and not empty strings? Maybe for password ?
  2. Does the integration test handle the scenario where all 4 combinations of these 2 parameters are set ?

* Validates that the source configuration is valid. Throws IllegalArgumentException if the
* configuration is invalid.
*/
void validateFields();

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.

If the validation is implemented at the source, then it can be private.

This method should not be required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This only validates the null checks and basic checks. It is called by the SourceConfigParser before returning the config.

Interface fields cannot be private.

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.

If validate is called in each of the flows right after reading the config, then this validation is not really achieving anything. Especially if the code of what to validate is within the source implementation.

The value of the validate would be if it lies outside of the source implementation. Can you think of a scenario where the source specific validation can not be done while reading the source config ?

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.

2 participants