https://prefect.io logo
Title
m

Michał

12/21/2022, 2:24 PM
Hey, guys I have problem with agent after succesffully runned flow (all 'tasks" run and finish but seting state fails:
For more information check: <https://httpstatuses.com/422>
15:18:47.351 | INFO | prefect.agent - Completed submission of flow run '5adc8699-d9a5-4042-85d0-0b072a4873d0' <frozen runpy>:128: RuntimeWarning: 'prefect.engine' found in sys.modules after import of package 'prefect', but prior to execution of 'prefect.engine'; this may result in unpredictable behaviour 15:18:48.970 | INFO | Flow run 'fantastic-tamarin' - Hello from demo-flow! 15:18:48.995 | ERROR | Flow run 'fantastic-tamarin' - Crash detected! Execution was interrupted by an unexpected exception: httpx.HTTPStatusError: Client error '422 Unprocessable Entity' for url 'http://prefect-server:4200/api/flow_runs/5adc8699-d9a5-4042-85d0-0b072a4873d0/set_state'
k

Khuyen Tran

12/21/2022, 5:17 PM
Hi @Michał, do you mind shortening your error message and post the full error in the comment to keep the channel clean? Can you also share an example of the code that causes the error?
m

Michał

12/21/2022, 5:18 PM
@Khuyen Tran Yeah, ofcourse For more information check: https://httpstatuses.com/422 15:18:49.058 | ERROR | prefect.engine - Engine execution of flow run '5adc8699-d9a5-4042-85d0-0b072a4873d0' exited with unexpected exception Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 1898, in <module> enter_flow_run_engine_from_subprocess(flow_run_id) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 188, in enter_flow_run_engine_from_subprocess return anyio.run(retrieve_flow_then_begin_flow_run, flow_run_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/anyio/_core/_eventloop.py", line 70, in run return asynclib.run(func, *args, **backend_options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 292, in run return native_run(wrapper(), debug=debug) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper return await func(*args) ^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/client/utilities.py", line 47, in with_injected_client return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 306, in retrieve_flow_then_begin_flow_run return await begin_flow_run( ^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 222, in aexit await self.gen.athrow(typ, value, traceback) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 1594, in report_flow_run_crashes raise exc from None File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 1574, in report_flow_run_crashes yield File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 372, in begin_flow_run terminal_or_paused_state = await orchestrate_flow_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 697, in orchestrate_flow_run state = await propose_state( ^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/engine.py", line 1741, in propose_state response = await client.set_flow_run_state( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/client/orion.py", line 1549, in set_flow_run_state response = await self._client.post( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 1848, in post return await self.request( ^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 1533, in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prefect/client/base.py", line 251, in send response.raise_for_status() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_models.py", line 745, in raise_for_status raise HTTPStatusError(message, request=request, response=self) httpx.HTTPStatusError: Client error '422 Unprocessable Entity' for url 'http://prefect-server:4200/api/flow_runs/5adc8699-d9a5-4042-85d0-0b072a4873d0/set_state' For more information check: https://httpstatuses.com/422 15:18:49.339 | ERROR | prefect.infrastructure.process - Process 'fantastic-tamarin' exited with status code:
Ok I guess i found problem. When i check /api/
curl -X 'GET' \
  '<http://prefect-server:14200/api/admin/version>' \
  -H 'accept: application/json'
I found that even I use tag 2,7.3 i get version 2.4.5 in this endpoint when I downgraded my local prefect version from agent from 2.7.3 to 2.4.5 flows works and I don't get this 422 error. But when I got back to version 2.7.3 error is back.
t

Tibs

01/09/2023, 3:11 PM
I get this error after upgrading from 2.7.0 to 2.7.6..
t

Taylor Curran

01/09/2023, 5:39 PM
Updating to prefect-2.7.7 fixed this for me @Tibs
1