Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate that serializers generate bytes-like (or None) data #1420

Merged
merged 1 commit into from
Mar 10, 2018

Conversation

dpkp
Copy link
Owner

@dpkp dpkp commented Mar 8, 2018

Fixes #1327

Copy link
Collaborator

@tvoinarovskyi tvoinarovskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't like the asserts for validation, but in this case, it really is for an assertion. We don't expect the callback to fail.

@dpkp
Copy link
Owner Author

dpkp commented Mar 10, 2018

I think it is worth it here because the alternative is the very strange error in #1327

@dpkp dpkp merged commit b8d40b5 into master Mar 10, 2018
@dpkp dpkp deleted the validate_serialized_bytes branch March 10, 2018 16:53
@@ -551,6 +549,9 @@ def send(self, topic, value=None, key=None, partition=None, timestamp_ms=None):
value_bytes = self._serialize(
self.config['value_serializer'],
topic, value)
assert type(key_bytes) in (bytes, bytearray, memoryview, type(None))
assert type(value_bytes) in (bytes, bytearray, memoryview, type(None))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be using isinstance rather than type()?

sorry for the late review--we had a new baby two weeks ago, so I'm still catching up on things...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants