<#1732 Improve error handling in ShellTask> Pull r...
# flyte-github
a
#1732 Improve error handling in ShellTask Pull request opened by pradithya TL;DR Improve the error returned by
ShellTask
. As of now,
ShellTask
error message is not helpful since it doesn't capture the
stderr
from the subprocess. Additionally, the error thrown by
ShellTask
is currently classified as system error instead of user error. Type ☑︎ Bug Fix ☐ Feature ☐ Plugin Are all requirements met? ☑︎ Code completed ☑︎ Smoke tested ☑︎ Unit tests added ☑︎ Code documentation added Complete description • Raise
FlyteRecoverableError
from
ShellTask
so that it's classified as user's error and the retry policy specified in the task is respected. • Improve the error message captured by
ShellTask
. As of now the error message generated by
ShellTask
in flyteconsole looks as follows. Notice that it doesn't contain any details of the failed command.
Copy code
[3/3] currentAttempt done. Last Error: SYSTEM::Traceback (most recent call last):

      File "/usr/local/lib/python3.8/site-packages/flytekit/exceptions/scopes.py", line 165, in system_entry_point
        return wrapped(*args, **kwargs)
      File "/usr/local/lib/python3.8/site-packages/flytekit/core/base_task.py", line 527, in dispatch_execute
        raise e
      File "/usr/local/lib/python3.8/site-packages/flytekit/core/base_task.py", line 524, in dispatch_execute
        native_outputs = self.execute(**native_inputs)
      File "/usr/local/lib/python3.8/site-packages/flytekit/extras/tasks/shell.py", line 220, in execute
        subprocess.check_call(gen_script, shell=True)
      File "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)

Message:

    Command '
        export RUN_DATE=2023-07-04 &&
        make run
    ' returned non-zero exit status 2.

SYSTEM ERROR! Contact platform administrators.
With this change, users would be able to see
stdout
and
stderr
of the subprocess as part of the error message. Tracking Issue flyteorg/flyte#3559 Follow-up issue N.A. flyteorg/flytekit All checks have passed 30/30 successful checks