module-ballerina-grpc icon indicating copy to clipboard operation
module-ballerina-grpc copied to clipboard

fix: improve proto enum mismatch error messages

Open heysagnik opened this issue 1 month ago • 6 comments
trafficstars

  • 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

heysagnik avatar Oct 09 '25 20:10 heysagnik

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 09 '25 20:10 CLAassistant

@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.

daneshk avatar Oct 15 '25 06:10 daneshk

Sure, Could I do those changes in the new PR or this PR only ? As I am participating in Hacktoberfest , so...

heysagnik avatar Oct 15 '25 11:10 heysagnik

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.

daneshk avatar Oct 23 '25 08:10 daneshk

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).

Files with missing lines Patch % Lines
...rc/main/java/io/ballerina/stdlib/grpc/Message.java 16.27% 35 Missing and 1 partial :warning:
...main/java/io/ballerina/stdlib/grpc/ServerCall.java 0.00% 3 Missing :warning:
...main/java/io/ballerina/stdlib/grpc/ClientCall.java 0.00% 2 Missing :warning:

: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.

codecov[bot] avatar Oct 23 '25 08:10 codecov[bot]