Open Sparrow1029 opened 6 months ago
@Sparrow1029 Seems like you hit a cornercase. Is the type you are trying to serialise actually Any
? If possible I would suggest to use the actual type you want. I think the preferred solution to this bug, would be to raise a readable error and suggest the user to use the "actual" type they want or otherwise use the "state" paramater, and do state.get("variable"). Correct casting from the database can only go so far.
I've created an internal issue to write a fix.
@pboers1988 You are correct that Any
was not the actual type (it was supposed to be dict[str, ...]
I think). For sure not using Any
is the solution, but since I ran into it, figured I'd report it. Providing a meaningful error message is the right approach for a fix. Thanks for your response -- also I'm happy to take the task and make an MR!
Providing a meaningful error message is the right approach for a fix.
We agree that this is the best solution. Would be great to receive an MR for this, thanks!
Contact Details
awray2@es.net
What happened?
When a function wrapped with the
@step
decorator defines an argument of typelist[typing.Any]
, the_build_arguments
function inorchestrator/utils/state.py
hits this code block:https://github.com/workfloworchestrator/orchestrator-core/blob/0418589847e7560718cabfc9b3a756c3392e56d0/orchestrator/utils/state.py#L184-L189
Because
typing.Any
is compatible with any type, and any method call is considered valid, the code attempts to serialize the list objects intoSubscriptionModel
s via thefrom_subscription
method, which throws an attribute error.Version
2.0.0
What python version are you seeing the problem on?
Python 3.11
Relevant log output