https://prefect.io logo
Title
j

Jon

01/19/2023, 9:48 PM
hey all, in prefect 1, i'm expecting a
None
value as a task result with
get_task_run_result
. i'm getting this error:
Task 'get_task_run_result[17]': Exception encountered during task execution!
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/prefect/engine/task_runner.py", line 880, in get_task_run_state
    value = prefect.utilities.executors.run_task_with_timeout(
  File "/usr/local/lib/python3.9/site-packages/prefect/utilities/executors.py", line 468, in run_task_with_timeout
    return task.run(*args, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/prefect/tasks/prefect/flow_run.py", line 239, in get_task_run_result
    return task_run.get_result()
  File "/usr/local/lib/python3.9/site-packages/prefect/backend/task_run.py", line 75, in get_result
    self._assert_result_type_is_okay()
  File "/usr/local/lib/python3.9/site-packages/prefect/backend/task_run.py", line 162, in _assert_result_type_is_okay
    raise ValueError(
ValueError: The task result has no `location` so the result cannot be loaded. This often means that your task result has not been configured or has been configured incorrectly.
is there a way to for me to access a task's result if it's
None
? My code works when i pass an
int
z

Zanie

01/19/2023, 9:52 PM
Ah we don’t persist
None
results to avoid writing to files when there’s no data.
j

Jon

01/19/2023, 9:54 PM
gotcha
j

Jon

01/19/2023, 9:59 PM
is there a way to silence/handle that error?
z

Zanie

01/19/2023, 10:01 PM
How are you retrieving the result of that task?
Usually these results are cached in memory
j

Jon

01/19/2023, 10:09 PM
this is with the flow of flows patterns
so in the parent flow i'm using
get_task_run_result
to get the result of a task in the child flow
z

Zanie

01/19/2023, 10:20 PM
Ah I see. That makes sense. I’d recommend just returning a different value to represent data in this case. Alternatively, you could use a utility to capture this value error when getting the result and return
None
instead.
j

Jon

01/19/2023, 11:00 PM
i'll just return something else, thanks for your help here 🙂