-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Bug summary
I am not able to run automations in case the Prefect Server is started with custom PREFECT_SERVER_API_BASE_PATH
. I get prefect.automation.action.failed
event with reason
set to "Unexpected status from 'run-deployment' action: 404". Full event JSON:
{
"id": "019884c0-7bd2-7d4d-865a-04a45ce119ed",
"event": "prefect.automation.action.failed",
"occurred": "2025-08-07T13:37:43.890Z",
"payload": {
"action_index": 0,
"action_type": "run-deployment",
"invocation": "019884c0-7b6f-70f5-b9e1-18f81b38b945",
"reason": "Unexpected status from 'run-deployment' action: 404",
"status_code": 404
},
"received": "2025-08-07T13:37:43.890Z",
"related": [
{
"prefect.resource.id": "prefect.deployment.848d53c7-34e7-4384-a7b4-e5d6c4cacf34",
"prefect.resource.role": "target"
}
],
"resource": {
"prefect.resource.id": "prefect.automation.7f3a6f7b-c63c-46b0-9673-3cc5cceee925",
"prefect.resource.name": "one-starts-two",
"prefect.trigger-type": "event",
"prefect.posture": "Reactive"
}
}
Currently we cannot run automations with our self-hosted OSS Prefect Server. We run it our K8s cluster and route to it, such that the in-cluster URL is http://prefect-server.services.svc.cluster.local:4200/prefect/api
.
Steps to reproduce with local Prefect Server:
- Create flows.py:
from prefect import flow, serve
@flow(log_prints=True)
def one():
print("one is running")
@flow(log_prints=True)
def two():
print("two is running")
if __name__ == "__main__":
one_dep = one.to_deployment(name="one-dep")
two_dep = two.to_deployment(name="two-dep")
serve(one_dep, two_dep)
-
Serve with
python flow.py
. -
Create profile for the local server, set environment and start it:
prefect profile create automation-error
prefect profile use 'automation-error'
prefect config set PREFECT_API_URL='http://127.0.0.1:4200/prefect/api'
prefect config set PREFECT_SERVER_API_BASE_PATH='/prefect/api'
prefect config set PREFECT_UI_SERVE_BASE=/prefect
prefect server start
- Create an automation in the UI from http://127.0.0.1:4200/prefect/automations page:

Action YAML that I pulled with `prefect automations inspect one-starts-two --yaml`
- name: one-starts-two
description: ''
enabled: true
tags: []
trigger:
type: event
match:
prefect.resource.id: prefect.flow-run.*
match_related:
prefect.resource.role: flow
prefect.resource.id:
- prefect.flow.c61daf5a-fcb3-41cd-9d4b-996643fcc003
after: []
expect:
- prefect.flow-run.Completed
for_each:
- prefect.resource.id
posture: Reactive
threshold: 1
within: 0.0
actions:
- type: run-deployment
source: selected
deployment_id: 848d53c7-34e7-4384-a7b4-e5d6c4cacf34
parameters: {}
job_variables: null
actions_on_trigger: []
actions_on_resolve: []
owner_resource: null
id: 7f3a6f7b-c63c-46b0-9673-3cc5cceee925
-
Trigger deployment
one/one-dep
and expect the automation to run deploymenttwo/two-dep
as per automation configuration. -
Observe events with error mentioning 404.

Tentaive fix
I was able to fix it locally with the following diff (inspired by fix of #18045 by @chrisguidry):
diff --git a/src/prefect/server/api/clients.py b/src/prefect/server/api/clients.py
index 46af57496..a5afbcab6 100644
--- a/src/prefect/server/api/clients.py
+++ b/src/prefect/server/api/clients.py
@@ -18,7 +18,7 @@ from prefect.server.schemas.actions import DeploymentFlowRunCreate, StateCreate
from prefect.server.schemas.core import WorkPool
from prefect.server.schemas.filters import VariableFilter, VariableFilterName
from prefect.server.schemas.responses import DeploymentResponse, OrchestrationResult
-from prefect.settings import get_current_settings
+from prefect.settings import PREFECT_SERVER_API_BASE_PATH, get_current_settings
from prefect.types import StrictVariableValue
if TYPE_CHECKING:
@@ -50,7 +50,7 @@ class BaseClient:
self._http_client = PrefectHttpxAsyncClient(
transport=httpx.ASGITransport(app=api_app, raise_app_exceptions=False),
headers={**additional_headers},
- base_url="http://prefect-in-memory/api",
+ base_url=f"http://prefect-in-memory{PREFECT_SERVER_API_BASE_PATH}",
enable_csrf_support=settings.server.api.csrf_protection_enabled,
raise_on_all_errors=False,
)
With this fix, I was able to get my automation to start two/two-dep
, when one/one-dep
completed.
Version info
Version: 3.4.11
API version: 0.8.4
Python version: 3.13.5
Git commit: 3c98aa7f
Built: Thu, Jul 31, 2025 08:45 PM
OS/Arch: darwin/arm64
Profile: local-base-name
Server type: server
Pydantic version: 2.11.7
Integrations:
prefect-kubernetes: 0.1.dev11+gf6e37d7.d20250801
Additional context
No response