module-ballerina-grpc
module-ballerina-grpc copied to clipboard
fix: improve proto enum mismatch error messages
- Add descriptive error messages for unknown enum values in Message.java
- Extract duplicate enum validation logic into reusable helper method
- Optimize error messages for large enums (limit to 10 values + count)
- Add edge case handling for null/empty enum descriptors
- Improve exception handling in ClientCall and ServerCall for null messages
Fixes issue where proto definition mismatches resulted in unhelpful 'Failed to read message. null.' errors. Now provides detailed information about field name, enum type, received value, and expected values.
Purpose
To solve the issue #3051
Examples
Checklist
- [x] Linked to an issue
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
@heysagnik Thanks for the fix. Could you please check the other scenarios as well, like the missing message field, incorrect message field type, etc?
We also need to add some test cases for this fix.
Sure, Could I do those changes in the new PR or this PR only ? As I am participating in Hacktoberfest , so...
Sure, Could I do those changes in the new PR or this PR only ? As I am participating in Hacktoberfest , so...
Better if we could do it in the same PR, as a proto mismatch can happen not only with enums.
Codecov Report
:x: Patch coverage is 14.58333% with 41 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 79.99%. Comparing base (452df72) to head (c19fa93).
:x: Your project check has failed because the head coverage (79.99%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.
Additional details and impacted files
@@ Coverage Diff @@
## master #1731 +/- ##
============================================
- Coverage 80.13% 79.99% -0.15%
- Complexity 0 56 +56
============================================
Files 73 76 +3
Lines 5438 5644 +206
Branches 1101 1154 +53
============================================
+ Hits 4358 4515 +157
- Misses 681 710 +29
- Partials 399 419 +20
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.