Hi. I'm having this issue when calling `client.rea...
# ask-community
c
Hi. I'm having this issue when calling
client.read_flow_runs()
API... it gives me a pydantic validation error whenever the returned flow run(s) have a
"state": { "data": {"type": "unpersisted"} }
property... is this something that was overlooked in development? Not sure how to deal with this:
Copy code
File "C:\Web Apps\Prefect2.0-Flows\flows\Python\Snowflake\ff_gl_stats_sf_load.py", line 22, in get_completed_flow_runs_with_flow_name
    flow_runs = await client.read_flow_runs(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Web Apps\Prefect2.0-Flows\venv\Lib\site-packages\prefect\client\orchestration.py", line 2148, in read_flow_runs
    return pydantic.TypeAdapter(List[FlowRun]).validate_python(response.json())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Web Apps\Prefect2.0-Flows\venv\Lib\site-packages\pydantic\type_adapter.py", line 135, in wrapped
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Web Apps\Prefect2.0-Flows\venv\Lib\site-packages\pydantic\type_adapter.py", line 366, in validate_python
    return self.validator.validate_python(object, strict=strict, from_attributes=from_attributes, context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for list[FlowRun]
0.state.data.BaseResult
  Value error, Invalid type: unpersisted [type=value_error, input_value={'type': 'unpersisted'}, input_type=dict]
NOTE: This only happens on Prefect 3.0+ version, does not occur on my other work queues that are still in 2.*
i
Bumping this issue as we are getting the same error. We are experiencing the same issue when running tasks that run
run_deployment
to kick off a separate deployment. Our tasks that don't call this function are working properly. Each time we encounter the issue we get the following two errors as logs to our tasks:
Copy code
Running `retry_condition_fn` check None for task 'task-name'

Task run failed with exception: 1 validation error for FlowRun
state.data.BaseResult
  Value error, Invalid type: unpersisted [type=value_error, input_value={'type': 'unpersisted'}, input_type=dict]
    For further information visit <https://errors.pydantic.dev/2.9/v/value_error>
🤔 1
@Carlos Cueto Please let us know if you find anything out and we will do the same!
c
Hi! Could you open an issue for this on GitHub along with a minimum reproducible example? I think this may be related to different client-side versions of Prefect, so when you do open the issue please include all relevant versions of Prefect that are being used (on the deployment and on the client reading flow runs)
i
AHHHH. That could definitely be the culprit. Specifically we have existing deployments that use prefect 2.X and are trying to orchestrate them using prefect 3.X. Let me see if I can simplify the issue further to get a MRE. Also thanks for the quick response and diagnosis!
c
ahhhhh that would do it! I think we can figure out a way to make 3.x not fail so aggressively in that situation, so still room for improvement 🫡
i
No problem. out of curiosity are you aware of any intentions to make this a possibility in the near future? If not thats totally fine and we will likely try to bump things to all use the same version.
c
I think we would try to resolve this quickly but it's hard to say for sure if it will be complex or not; my hope is that we can ignore
unpersisted
result types entirely without raising an error, but that will require unraveling some of the pydantic machinery so it could go either way
i
I totally understand. We won't plan on waiting for you guys to solve our problem hahah. We'll make sure to get everything on the same version. Would you still like me to create an issue illustrating that we get the issue when running a 2.X deployment from 3.X? Interestingly, it runs the deployment fine, however, once the flow run has completed, the
run_deployment
is unable to reconcile the
unpersisted
type. For our purposes, as it successfully runs the deployment, we might be able to get away with catching the specific error as a workaround.
c
yea i'd love the issue so that we can track it and post updates for anyone else who runs into it -- hopefully we can also resolve it quickly 🤞
MRE maybe isn't so necessary since we basically know what the issue is, but a good description + copy of the traceback will help people discover the issue if they run into the same error
i
Awesome. Will do.
c
thank you!