taskiq-python / taskiq

Distributed task queue with full async support
MIT License
808 stars 50 forks source link

If label is not str worker fails without traceback #278

Open AnikinNN opened 8 months ago

AnikinNN commented 8 months ago

If a label with a type different from str is added anywhere in the worker task, the task will fail.

@broker.task
async def generation_task(params: RequestParams, context: Annotated[Context, TaskiqDepends()]):
    result = do_some_work(params)
    context.message.labels['non_str_field'] = 42
    return result

I suspect the issue lies in the construction of the TaskiqResult object at /taskiq/receiver/receiver.py:294.

While it's acceptable for the task to fail on unknown types, the problem is that it doesn't display anything in the log. This lack of information made it necessary for me to spend extra time figuring out what went wrong.

Perhaps, to make this workaround clearer, we could consider adding some logging?

s3rius commented 8 months ago

Totally agree on that one.

That's weird that receiver fails after non-string label. Also we have this PR waiting to be merged that might solve your issue as well.

https://github.com/taskiq-python/taskiq/pull/243