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

karapace.protobuf.encoding_variants.write_varint is broken #651

Open
aiven-anton opened this issue Jun 8, 2023 · 1 comment · May be fixed by #653
Open

karapace.protobuf.encoding_variants.write_varint is broken #651

aiven-anton opened this issue Jun 8, 2023 · 1 comment · May be fixed by #653

Comments

@aiven-anton
Copy link
Contributor

What happened?

Another bug found while adding type-hints. BytesIO.write() does not accept an int, which is always the result of subscripting a bytearray. There does not seem to be any unit test coverage here.

https://github.com/aiven/karapace/blob/0d0ede8edbba65cc944bb5fbc5df28fdfcdd3bd3/karapace/protobuf/encoding_variants.py#L48

>>> from karapace.protobuf.encoding_variants import *
>>> b = BytesIO()
>>> write_varint(b, 123)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/anton/aiven/karapace/karapace/protobuf/encoding_variants.py", line 65, in write_varint
    bio.write(bytearray(to_write)[0])
TypeError: a bytes-like object is required, not 'int'

Not entirely clear what to do about this as it indicates that quite a lot of code is unused, i.e. if this breakage isn't affecting functionality.

@aiven-anton aiven-anton linked a pull request Jun 9, 2023 that will close this issue
@aiven-anton
Copy link
Contributor Author

Tests in this PR encodes this failure as well as other oddities in the same module: https://github.com/aiven/karapace/pull/653/files

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 a pull request may close this issue.

1 participant