dbos-inc / dbos-transact-py

Ultra-Lightweight Durable Execution in Python
https://docs.dbos.dev
MIT License
244 stars 7 forks source link

Detect functions passed instead of serializable arguments #109

Closed chuck-dbos closed 1 month ago

chuck-dbos commented 1 month ago

For #111

Detect functions passed as arguments / return values to DBOS functions, and stop them.

Put a little more type info on WorkflowInput, and split the serialization cases a little.

Generally, we may not want "unpicklable" items in the serializer, but Kafka currently uses it.

Editorial comment, if this code is catching something, I wonder if the end developer is using mypy or similar. Hate to preach, but they're making a big mistake if they don't... are we adequately stressing this?

chuck-dbos commented 1 month ago

Looks good! I wish there was a more general fix (this wouldn't catch the specific problem that was originally reported, where the bad input was actually a dict that contained functions) but it's a good start that we can refine.

Been thinking about that a bit. An object with some fields and helper functions is kinda fine. A dict with functions, that we could catch I think. We could iterate lists and dicts and make sure there was nothing weird in them.