Skip to content

Add checks on thrift files based on ID#846

Merged
vikrantpuppala merged 1 commit into
mainfrom
internal-thrift-fields
Jun 9, 2025
Merged

Add checks on thrift files based on ID#846
vikrantpuppala merged 1 commit into
mainfrom
internal-thrift-fields

Conversation

@vikrantpuppala

@vikrantpuppala vikrantpuppala commented Jun 3, 2025

Copy link
Copy Markdown
Collaborator

Description

Add checks on thrift files based on ID

Testing

Added test, verified by changing ID of a field locally and test failed

Additional Notes to the Reviewer

NO_CHANGELOG=true

Copilot AI 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.

Pull Request Overview

This PR adds a test ensuring that all Thrift-generated classes have field IDs below the reserved maximum value to prevent compatibility issues.

  • Implements a file walker to check generated Java files for valid Thrift field IDs.
  • Logs any violations and fails the test if any field ID exceeds the allowed value.
Comments suppressed due to low confidence (1)

src/test/java/com/databricks/jdbc/dbclient/impl/thrift/ThriftGeneratedFieldIdTest.java:90

  • The ClassNotFoundException is caught and only logged, which might mask misconfigurations or issues with the generated classes. Consider failing the test or adding a warning to ensure these cases are appropriately flagged during execution.
catch (ClassNotFoundException e) {

TFieldIdEnum thriftField = (TFieldIdEnum) fieldDefinition;
short fieldId = thriftField.getThriftFieldId();

if (fieldId >= MAX_ALLOWED_FIELD_ID) {

Copilot AI Jun 3, 2025

Copy link

Choose a reason for hiding this comment

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

The conditional check uses '>= MAX_ALLOWED_FIELD_ID' while the error message subtracts one from the constant. Consider clarifying the logic or documenting why the allowable maximum is effectively (MAX_ALLOWED_FIELD_ID - 1) to avoid future confusion.

Copilot uses AI. Check for mistakes.

@gopalldb gopalldb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Elaborate testing section, thanks for adding this!

@vikrantpuppala vikrantpuppala merged commit 0790e02 into databricks:main Jun 9, 2025
22 of 24 checks passed
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.

4 participants