https://prefect.io logo
Title
s

Scott Zelenka

03/17/2020, 9:17 PM
Hi Team, how do I troubleshoot this error message:
March 17th 2020 at 5:13:44pm | prefect.CloudTaskRunner
INFO 
Task 'sfdc_download_data': Starting task run...March 17th 2020 at 5:13:44pm | prefect.CloudTaskRunner
ERROR 
Unexpected error: KeyError('text')
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/prefect/engine/runner.py", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/prefect/engine/cloud/task_runner.py", line 225, in check_task_is_cached
    for key, res in (candidate_state.cached_inputs or {}).items()
  File "/usr/local/lib/python3.7/site-packages/prefect/engine/cloud/task_runner.py", line 225, in <dictcomp>
    for key, res in (candidate_state.cached_inputs or {}).items()
KeyError: 'text'
It seems to be related to this task:
@task(
    max_retries=3,
    retry_delay=datetime.timedelta(minutes=5),
    cache_for=datetime.timedelta(days=1),
    cache_validator=cache_validators.duration_only
)
def sfdc_download_data(
        url: typing.Union[str, Parameter]
) -> typing.Union[str, Result]:
    ...
but there's no
text
parameter in this Task ... where is the task_runner getting this cached_input from?
j

josh

03/17/2020, 9:48 PM
Were you ever using
text
in relation to this task? To me it looks like the cache duration has not passed so the cached inputs are retrieved from cloud but then the inputs to your task runner no longer have that text attribute
s

Scott Zelenka

03/17/2020, 10:06 PM
Not that task, but another task (with a different function name) in the same Flow (which is also attempting to cache) does have a
text
and
url
parameter. My assumption was that if it detected a change in the task inputs, it would invalidate the cache and recompute it. Or in this case, if it failed to load the previous cache, it would invalidate and retry. How does one force an invalidation of the cache without waiting for the original duration setting?
j

josh

03/17/2020, 11:34 PM
The only way to delete this cached input would be to delete the cached state from Cloud or wait out the duration. I see room for improvement here because your expected behavior makes a lot of sense. i.e. if the cached inputs are different then it should not attempt to use the cache because they would not match