Oz Shaked
10/10/2024, 10:45 AMjson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
errors.
What is the most reliable version currently?
Few examples of use with errors:
1. When trying to deploy a flow to a None existing Work Pool the the server doesn't return 404 error from the address but 200 with HTML page of 404:
File "/workspaces/prefect-poc/.venv/lib/python3.11/site-packages/prefect/client/orchestration.py", line 2658, in read_work_pool return WorkPool.model_validate(response.json()).
The server returns an HTML in response to the request:
'<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <link rel="apple-touch-icon" sizes="180x180" href="/ico/apple-touch-icon.png">\n \n \n \n <link rel="icon" id="favicon-32" type="image/png" sizes="32x32" href="/ico/favicon-32x32.png" media="(prefers-color-scheme:light)">\n <link rel="icon" id="favicon-16" type="image/png" sizes="16x16" href="/ico/favicon-16x16.png" media="(prefers-color-scheme:light)">\n\n <link rel="icon" id="favicon-32-dark" type="image/png" sizes="32x32" href="/ico/favicon-32x32-dark.png" media="(prefers-color-scheme:dark)">\n <link rel="icon" id="favicon-16-dark" type="image/png" sizes="16x16" href="/ico/favicon-16x16-dark.png" media="(prefers-color-scheme:dark)">\n \n <link rel="icon" href="/favicon.ico" media="(prefers-color-scheme:no-preference)">\n <link rel="icon" href="/favicon.ico" media="(prefers-color-scheme:light)">\n <link rel="icon" href="/favicon-dark.ico" media="(prefers-color-scheme:dark)">\n\n <link rel="manifest" href="/ico/site.webmanifest">\n <link rel="mask-icon" href="/ico/safari-pinned-tab.svg" color="#5bbad5">\n \n <meta name="msapplication-TileColor" content="#da532c">\n <meta name="theme-color" content="#ffffff">\n\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>Prefect Server</title>\n <script type="module" crossorigin src="/assets/index-DGGjalVM.js"></script>\n <link rel="stylesheet" crossorigin href="/assets/index-0K-9VP3A.css">\n </head>\n <body>\n <div id="app"></div>\n </body>\n</html>\n'
The code that gets the error:
flow.from_source(
source=str(Path(__file__).parent),
entrypoint="prefect_create_deployment.py:test_flow",
).deploy(
name="print-deployment-k8s-process",
work_pool_name="Process Worker", # Work pool target
triggers=[
events.DeploymentEventTrigger(
name="Print Trigger",
enabled=True,
match={},
expect=["Run Deployment Process"],
parameters={
"event_details": "{{ event.payload }}",
},
)
],
)
2. When trying to work with prefect.client.orchestration.get_client
with the function create_work_pool
for some reason the client creates the following request:
<Request('GET', '<http://127.0.0.1:4200/csrf-token?client=6bd93e79-f5a8-46b2-b99f-b88891b2d3e0>')>
Which get the 200 response (seems like the 404):
'<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <link rel="apple-touch-icon" sizes="180x180" href="/ico/apple-touch-icon.png">\n \n \n \n <link rel="icon" id="favicon-32" type="image/png" sizes="32x32" href="/ico/favicon-32x32.png" media="(prefers-color-scheme:light)">\n <link rel="icon" id="favicon-16" type="image/png" sizes="16x16" href="/ico/favicon-16x16.png" media="(prefers-color-scheme:light)">\n\n <link rel="icon" id="favicon-32-dark" type="image/png" sizes="32x32" href="/ico/favicon-32x32-dark.png" media="(prefers-color-scheme:dark)">\n <link rel="icon" id="favicon-16-dark" type="image/png" sizes="16x16" href="/ico/favicon-16x16-dark.png" media="(prefers-color-scheme:dark)">\n \n <link rel="icon" href="/favicon.ico" media="(prefers-color-scheme:no-preference)">\n <link rel="icon" href="/favicon.ico" media="(prefers-color-scheme:light)">\n <link rel="icon" href="/favicon-dark.ico" media="(prefers-color-scheme:dark)">\n\n <link rel="manifest" href="/ico/site.webmanifest">\n <link rel="mask-icon" href="/ico/safari-pinned-tab.svg" color="#5bbad5">\n \n <meta name="msapplication-TileColor" content="#da532c">\n <meta name="theme-color" content="#ffffff">\n\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>Prefect Server</title>\n <script type="module" crossorigin src="/assets/index-DGGjalVM.js"></script>\n <link rel="stylesheet" crossorigin href="/assets/index-0K-9VP3A.css">\n </head>\n <body>\n <div id="app"></div>\n </body>\n</html>\n'
And again the client fails to get the json from the response in the line:
CsrfToken = CsrfToken.model_validate(token_response.json())
So which version should I work with? (had the same with 3.0.6)
Any recommendations? Should I reimplement my own Rest API client and should work with the python client?Oz Shaked
10/10/2024, 12:32 PMPREFECT_API_URL=<http://localhost:4200/api>
I defined it as so kept getting 404 (as html) which broke the httpx
PREFECT_API_URL=<http://localhost:4200>
Sorry for that 🥴Nate
10/10/2024, 3:32 PM