<#3434 fix: coerce int error_code to str to preven...
# flyte-github
a
#3434 fix: coerce int error_code to str to prevent proto serialization failure Pull request opened by AdilFayyaz Why are the changes needed? When a user task raises a custom exception with a non-string error_code (e.g. an integer HTTP status code), flytekit passed it directly to protobuf's string code field, causing TypeError: bad argument type for built-in operation inside ContainerError.to_flyte_idl(). This hid the original actionable exception from the UI entirely. What changes were proposed in this pull request? • FlyteUserRuntimeException.error_code now coerces int error codes to str instead of passing them raw to protobuf • None error codes fall back to the default "USER:RuntimeError" code • Any other unsupported type raises FlyteException with a clear message rather than producing a cryptic TypeError deep in serialization • Added unit tests covering str passthrough, int coercion, None fallback, and unsupported-type raise; added an integration test that exercises the full _dispatch_execute → to_flyte_idl() → ErrorDocument.from_flyte_idl() round-trip How was this patch tested? • Run pytest tests/flytekit/unit/exceptions/test_user.py — covers all error_code coercion cases • Run pytest tests/flytekit/unit/bin/test_python_entrypoint.py::test_dispatch_execute_non_string_error_code_serializes_cleanly — integration test using a real task that raises an exception with error_code = 422, verifying the error file is written with code == "422" and the original exception message is preserved Setup process Screenshots Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. Related PRs Docs link flyteorg/flytekit