Skip to content

[BUG] CallableProxy ignores kwargs and only works with args #815

@Chumper

Description

@Chumper

Expected Behavior

When using the CallableProxy, I expect args and kwargs to work, so I expect this to work:

class DemoActorInterface(ActorInterface):
    @actormethod(name="GetMyData")
    async def get_my_data(self, test: str) -> object:

...

    # Create proxy client
    proxy = ActorProxy.create('DemoActor', ActorId('1'), DemoActorInterface)

    # Call method on client
    resp = await proxy.GetMyData("my-string")
    resp = await proxy.GetMyData(test="my-string")

Actual Behavior

Only the first call works, because the string is passed as arg,
the second will send an empty payload, because it is a kwargs.

This is the CallableProxy code:
https://github.com/dapr/python-sdk/blob/147f1c4ffc0a43887c63f592011414aa5a130dea/dapr/actor/client/proxy.py#L81C1-L94C98

async def __call__(self, *args, **kwargs) -> Any:
        if len(args) > 1:
            raise ValueError('does not support multiple arguments')

        bytes_data = None
        if len(args) > 0:
            if isinstance(args[0], bytes):
                bytes_data = args[0]
            else:
                bytes_data = self._message_serializer.serialize(args[0])

        rtnval = await self._proxy.invoke_method(self._attr_call_type['actor_method'], bytes_data)

This completely ignores arguments passed as kwargs

Steps to Reproduce the Problem

Use the demo, require a parameter, call the proxy as shown above.
The first gets the string, the second will not.

Release Note

RELEASE NOTE: FIX CallableProxy now accepts kwargs next to args

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions