<@ULVA73B9P> [ERROR] HTTPError: 409 Client *Error*...
# ask-marvin
m
@Marvin [ERROR] HTTPError: 409 Client Error: Conflict for url: data-science-prefect-lb-547067713.ap-southeast-1.elb.amazonaws.com/api/deployments/20858931-dc02-4956-bbfb-704a6c9ed95e/create_flow_run Traceback (most recent call last): File "/var/task/lambda_function.py", line 84, in lambda_handler flow_run = run_prefect_flow(flow_name, deployment_name,params) File "/var/task/lambda_function.py", line 61, in run_prefect_flow flow_run = run_deployment_by_full_name(flow_name, deployment_name, parameters) File "/var/task/lambda_function.py", line 53, in run_deployment_by_full_name return create_flow_run_from_deployment(dep_id, parameters) File "/var/task/lambda_function.py", line 47, in create_flow_run_from_deployment r.raise_for_status() File "/var/task/requests/models.py", line 1026, in raise_for_status raise HTTPError(http_error_msg, response=self)
m
thought for 150.1 seconds
A
409 Conflict
on
POST /api/deployments/{id}/create_flow_run
in Prefect 3.x usually means the server rejected the run creation because something conflicted with deployment state, parameter validation, or database integrity. The most likely causes are: 1. Parameter schema validation failed If your deployment has parameter schema enforcement enabled, the parameters sent from Lambda must match the deployment’s schema exactly. Typical examples: - missing required parameters - wrong types - unexpected structure Prefect returns 409 for this case with a message like:
Copy code
text
Error creating flow run: ...
2. Schema enforcement is enabled, but the deployment has no valid schema If
enforce_parameter_schema=True
on the deployment, but the deployment’s stored schema is invalid or missing, Prefect can also return 409. 3. Database integrity conflict Prefect also maps DB integrity errors to 409. That usually means: - a foreign key / unique constraint issue - a race condition - duplicate creation behavior under concurrent Lambda invocations The generic message for this case is:
Copy code
text
Data integrity conflict. This usually means a unique or foreign key constraint was violated. See server logs for details.
4. In some newer versions: deployment is disabled A disabled deployment can also lead to a 409 when trying to create a flow run. What to check first Check your Prefect server logs The traceback you pasted only shows the client-side HTTP error. The real reason should be in the Prefect API server logs. Check the deployment definition Inspect: - whether parameter schema enforcement is on - whether the parameters you send from Lambda match expected names/types - whether the deployment is enabled You can query the deployment directly:
Copy code
text
GET /api/deployments/{id}
Look for fields related to: -
enforce_parameter_schema
-
parameter_openapi_schema
- deployment status / enabled state Validate the Lambda payload Make sure the body you send to
create_flow_run
looks like valid Prefect input, e.g.:
Copy code
json
{
  "parameters": {
    "x": 1,
    "y": "abc"
  }
}
If you’re sending custom JSON, double-check: - parameter names match the flow function signature - values are JSON-serializable - types match the deployment schema If Lambda may retry, use an idempotency key If multiple invocations can submit the same request, include `idempotency_key`:
Copy code
json
{
  "parameters": {
    "x": 1
  },
  "idempotency_key": "some-unique-request-id"
}
That helps avoid duplicate/conflicting run creation patterns. Most likely in your case Because you’re calling the API directly from Lambda, the first thing I’d suspect is parameter schema mismatch or a retry/concurrency-related conflict. If you want, paste: - the JSON body you send to
create_flow_run
- the deployment’s parameter schema / flow signature - the relevant Prefect API server log line for that request and I can help pinpoint the exact cause. Relevant docs: - Prefect deployments - Create flow run from deployment API - Deployment concepts