Skip to content
This repository was archived by the owner on Mar 24, 2021. It is now read-only.
This repository was archived by the owner on Mar 24, 2021. It is now read-only.

Please do not use Broker-side exceptions for Client-side errors #697

@jeffwidman

Description

@jeffwidman

When debugging #696 where the broker successfully returns a message to the consumer and then the consumer blows up, I was confused because the error that was raised was MessageSizeTooLarge which is a broker error code number 10: https://kafka.apache.org/protocol.html#protocol_error_codes

This was extremely confusing to me because initial spelunking in the pykafka source showed that this exception subclassed ProtocolClientError, indicating that the broker was returning the error code:

class MessageSizeTooLarge(ProtocolClientError):

Furthermore, it made no sense contextually because that error code is only emitted by the broker to a producer trying to produce too large of a message, not to a consumer.

It had me scratching my head until I realized that pykafka was re-using what is semantically a broker-side exception for a client-side error: https://github.com/Parsely/pykafka/blame/c80f66c0d0b11d830aa333ed486967b5f242bc2f/pykafka/protocol.py#L383

Digging a little deeper, I see that originally this exception wasn't the same as a broker-side error, but in #500 @emmett9001 changed it to re-use that exception class based on discussion in #497.

Can I request that you limit the use of broker-side exceptions to only situations where the broker is actually returning an error code?

In this particular case, the proper fix is probably removing this particular usage of the exception altogether as suggested in #696. If you choose to keep it a hard-limit and throw an exception, can you use an exception that more clearly indicates a client-side error? Probably with a suggestion to the user to increase their fetch_message_max_bytes setting.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions