Skip to content

Can you help me with alterpartitionreassignment #211

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

Open
f-r-kuznetsov opened this issue Apr 22, 2025 · 0 comments
Open

Can you help me with alterpartitionreassignment #211

f-r-kuznetsov opened this issue Apr 22, 2025 · 0 comments

Comments

@f-r-kuznetsov
Copy link

Hello, i understand, that partition reassignment is not public api for now, but i am need to use it. When use get strange errors with code like this

topics = [{
        "name": "supertopic",
        "partitions": [{
            "partitions_index": 0,
            "replicas": [2],
            "tags": {},
        }],
        "tags": {},
    }]
    return AlterPartitionReassignmentsRequest_v0(
        timeout_ms=timeout,
        topics=partitions
    )

Error is KeyError: 0
It happens when tries to encode object in CompactArray,

class CompactArray(Array):

    def encode(self, items):
        if items is None:
            return UnsignedVarInt32.encode(0)
        
        return b''.join(
            [UnsignedVarInt32.encode(len(items) + 1)] +
     -->       [self.array_of.encode(item) for item in items]
        )

    def decode(self, data):
        length = UnsignedVarInt32.decode(data) - 1
        if length == -1:
            return None
        return [self.array_of.decode(data) for _ in range(length)]

When encoding it put should put array in encode method, not dict

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

No branches or pull requests

1 participant