cuddly-jelly-27016
03/17/2025, 5:16 PM_ERROR_CODE attributes in exceptions that are raised in tasks so that our services know how to handle certain failures. For example, if an exception is raised that defines an _ERROR_CODE as "USER:NotReady", we treat that error code as a soft failure, and no alerting is triggered in such a case.
Currently, since this PR, when an exception is raised that defines its own _ERROR_CODE from a task, that error code is ignored and instead, "USER:RuntimeError" is passed whatever the case. The linked issue explains why this happens in more detail.
## What changes were proposed in this pull request?
This PR makes a change to the FlyteUserRuntimeException to make it consider the error_code attribute of the exception that it wraps, if that wrapped exception defines an error code. If this is not the case, it uses its default error code of "USER:RuntimeError".
This is so that if such a custom error code is defined in the original user-raised exception, it is propagated to the ContainerError which is eventually raised in _dispatch_execute().
## How was this patch tested?
Existing unit test was modified to verify the expected behaviour.
### 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
#3059
## Docs link
### Summary by Bito
This PR fixes error code propagation in FlyteUserRuntimeException by considering wrapped exceptions' error_code attributes. The implementation updates the exception module and modifies tests to verify that user-defined error codes are properly respected, resulting in more accurate error reporting and handling.
Unit tests added: True
Estimated effort to review (1-5, lower is better): 1
flyteorg/flytekitcuddly-jelly-27016
03/17/2025, 6:23 PM