Skip to content

Python PulsarClient::create_reader() doesn't accept MessageId instance #37

Closed
@gkimes

Description

@gkimes

Python pulsar-client package

Describe the bug
Attempting to provide the function PulsarClient::create_reader() with the param start_message_id as an instance of pulsar.MessageId raises an error. It only accepts a _pulsar.MessageId, which is the internal implementation of MessageId.

To Reproduce

    import pulsar 
    
    pulsar_client = pulsar.Client(
        PULSAR_URL,
        authentication=pulsar.AuthenticationToken(PULSAR_TOKEN),
    )
    message_id = pulsar.MessageId(ledger_id=LEDGER_ID, entry_id=ENTRY_ID)
    pulsar_client.create_reader(TOPIC, message_id)
Traceback (most recent call last):
    ... # my code
    pulsar_client.create_reader(TOPIC, message_id)
  File "/opt/conda/envs/base/lib/python3.8/site-packages/pulsar/__init__.py", line 825, in create_reader
    _check_type(_pulsar.MessageId, start_message_id, 'start_message_id')
  File "/opt/conda/envs/base/lib/python3.8/site-packages/pulsar/__init__.py", line 1338, in _check_type
    raise ValueError("Argument %s is expected to be of type '%s' and not '%s'"
ValueError: Argument start_message_id is expected to be of type 'MessageId' and not 'MessageId'

Expected behavior
Should allow a pulsar.MessageId instance to be provided. Current workaround is to either access the private property message_id._msg_id, or serialize & deserialize to get a _pulsar.MessageId instance.

Here is the line that performs the instance check and throws the error.

Versions

  • pulsar-client==2.10.0
  • Python 3.8.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions