Skip to content

[PECOBLR-595][PECOBLR-184] Add UID validation to always be token #909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 24, 2025

Conversation

vikrantpuppala
Copy link
Collaborator

@vikrantpuppala vikrantpuppala commented Jul 24, 2025

Description

This PR adds validation to ensure the UID parameter is always set to "token" or omitted entirely. This change enforces stricter parameter validation for JDBC connections and replaces the legacy USER parameter with UID across test files.

Replaces USER parameter with UID in all test files for consistency
Introduces new validation logic to enforce UID parameter must be "token" or empty
Adds comprehensive test coverage for UID validation scenarios

Testing

Unit + manual tests

Additional Notes to the Reviewer

Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@vikrantpuppala vikrantpuppala requested a review from Copilot July 24, 2025 06:19
Copilot

This comment was marked as outdated.

Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@vikrantpuppala vikrantpuppala changed the title Add UID validation to always be token [PECOBLR-595][PECOBLR-184] Add UID validation to always be token Jul 24, 2025
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@vikrantpuppala vikrantpuppala requested a review from Copilot July 24, 2025 06:28
Copilot

This comment was marked as outdated.

Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds validation to ensure the UID parameter is always set to "token" or omitted entirely. This change enforces stricter parameter validation for JDBC connections and replaces the legacy USER parameter with UID across test files.

  • Replaces USER parameter with UID in all test files for consistency
  • Introduces new validation logic to enforce UID parameter must be "token" or empty
  • Adds comprehensive test coverage for UID validation scenarios

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
DatabricksJdbcUrlParams.java Changes USER parameter to UID parameter
DatabricksJdbcConstants.java Adds VALID_UID_VALUE constant
ValidationUtil.java Implements UID validation logic
DatabricksVendorCodes.java New enum for centralized error codes
DatabricksConnectionContext.java Integrates validation into connection parsing
Exception classes Adds constructors supporting vendor codes
Test files Updates test code to use UID instead of USER
DatabricksConnectionContextTest.java Adds comprehensive UID validation tests
NEXT_CHANGELOG.md Documents the new validation feature
Comments suppressed due to low confidence (1)

src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionContextTest.java:694

  • The test only checks if the error message contains a substring. Consider also verifying the exact vendor code (DatabricksVendorCodes.INCORRECT_UID.getCode()) for more robust validation, similar to the other test methods.
    assertTrue(exception.getMessage().contains("Expected 'token' or omit UID parameter entirely"));

Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@@ -8,7 +8,7 @@ public enum DatabricksJdbcUrlParams {
LOG_PATH("logpath", "Path to the log file"),
LOG_FILE_SIZE("LogFileSize", "Maximum size of the log file", "10"), // 10 MB
LOG_FILE_COUNT("LogFileCount", "Number of log files to retain", "10"),
USER("user", "Username for authentication"),
UID("uid", "UID for authentication"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't this break for users using user currently ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • User is not a documented param in the JDBC driver
  • it was just being used in tests
  • if any user is nevertheless still using this field, it would just be ignored

Copy link
Collaborator

@jprakash-db jprakash-db left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for making the changes

@vikrantpuppala vikrantpuppala merged commit e5db63f into databricks:main Jul 24, 2025
12 checks passed
@vikrantpuppala vikrantpuppala deleted the error-codes branch July 24, 2025 07:08
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