[ 
https://issues.apache.org/jira/browse/KAFKA-17845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17891636#comment-17891636
 ] 

Colin McCabe edited comment on KAFKA-17845 at 10/21/24 6:40 PM:
----------------------------------------------------------------

> This is as if the `host` and `port` fields have defaults of empty string and 
> zero, but they do not. 

They do. 0 is the default of numeric fields if no other default is specified. 
The empty string is the default of string fields.

Protocol generators should handle cases where there is no tagged field as if 
the default values were in place. The default values are determined either by 
the specified "default" string or implicitly by type (0 for numerics, empty 
string for strings, zero-length collection for arrays, etc.)


was (Author: cmccabe):
> This is as if the `host` and `port` fields have defaults of empty string and 
> zero, but they do not. 

They do. 0 is the default of numeric fields if no other default is specified. 
The empty string is the default of string fields.

It sounds like this is not a bug, do you agree?

> UpdateRaftVoterResponse has incorrect default value fallbacks
> -------------------------------------------------------------
>
>                 Key: KAFKA-17845
>                 URL: https://issues.apache.org/jira/browse/KAFKA-17845
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 3.9.0
>            Reporter: Anton Agestam
>            Priority: Major
>
> This was discovered through property testing for upgrading kio to Kafka 
> 3.9.0-rc2 schema.
> We have tests in place to assert that our protocol serializer implementation 
> is sync with upstream Kafka.
> The test discovered a discrepancy between kio and Kafka for this instance:
>  
> {code:java}
> E           instance=UpdateRaftVoterResponse(
> E               throttle_time=datetime.timedelta(0),
> E               error_code=<ErrorCode.unknown_server_error: -1>,
> E               current_leader=CurrentLeader(
> E                   leader_id=-1,
> E                   leader_epoch=-1,
> E                   host='',
> E                   port=0,
> E               ),
> E           ), {code}
> kio serializes this as `"AAAAAP//AQAO//////////8BAAAAAAA="` while Kafka 
> serializes it as `"AAAAAP//AA=="` (base 64 encoded bytes).
> This is as if the `host` and `port` fields have defaults of empty string and 
> zero, but they do not. 
> This looks to me like the behavior for [deserializing a message from a 
> previous version 
> |https://github.com/apache/kafka/tree/trunk/clients/src/main/resources/common/message#deserializing-messages]
>  is incorrectly kicking in here.
> I would expect to either see the defaults declared in the schema, or for this 
> model to not exercise this "omit the nested entity" behavior at all, since 
> all of the fields of the nested entity do not have default values.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to