Add checks on thrift files based on ID#846
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
samikshya-db
approved these changes
Jun 3, 2025
gopalldb
approved these changes
Jun 5, 2025
gopalldb
left a comment
Collaborator
There was a problem hiding this comment.
Elaborate testing section, thanks for adding this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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