<@ULVA73B9P> I’m running a self-hosted Prefect ser...
# ask-marvin
b
@Marvin I’m running a self-hosted Prefect server and set up an automation via the UI. I configured a trigger that fires when a Flow remains in the Running state for a certain amount of time, and the corresponding action is set to Cancel the flow run. The trigger itself appears to work as expected, but the action fails. Below is a snippet of the raw log for reference: "event": "prefect.automation.action.failed", "occurred": "2025-07-14T130325.728Z", "payload": { "reason": "Unexpected status from 'change-flow-run-state' action: 404", "invocation": "06875001-da9e-712e-8000-466cbe969dd1", "action_type": "change-flow-run-state", "status_code": 404, "action_index": 0 } Do you know what is going on?
m
Error: status_code: 529, model_name: claude-3-5-sonnet-latest, body: {'type': 'error', 'error': {'type': 'overloaded_error', 'message': 'Overloaded'}}
Error: status_code: 529, model_name: claude-3-5-sonnet-latest, body: {'type': 'error', 'error': {'type': 'overloaded_error', 'message': 'Overloaded'}}
b
@Marvin Can you try again?
m
thought for 4.0 seconds
I notice this is your first message in our conversation, so there isn't anything to "try again." I'd be happy to help you with any questions you have about Prefect! Could you please let me know what specific question or topic you'd like to explore? I can help with: - Technical questions about Prefect features and functionality - Debugging issues or error messages - Understanding Prefect concepts - CLI commands and deployment strategies - Best practices and patterns Just let me know what you'd like to learn about, and I'll be glad to assist!
b
@Marvin I’m running a self-hosted Prefect server and set up an automation via the UI. I configured a trigger that fires when a Flow remains in the Running state for a certain amount of time, and the corresponding action is set to Cancel the flow run. The trigger itself appears to work as expected, but the action fails. Below is a snippet of the raw log for reference: "event": "prefect.automation.action.failed", "occurred": "2025-07-14T130325.728Z", "payload": { "reason": "Unexpected status from 'change-flow-run-state' action: 404", "invocation": "06875001-da9e-712e-8000-466cbe969dd1", "action_type": "change-flow-run-state", "status_code": 404, "action_index": 0 } Do you know what is going on?
m
thought for 36.5 seconds
Based on the error message and research, here's what's likely happening: 1. The 404 error suggests that when the automation tries to change the flow run state, it cannot find the flow run at the expected endpoint. This could happen for a few reasons: a. The flow run might have already been completed or deleted by the time the automation tries to cancel it b. There might be a version mismatch between your server and client c. The flow run might not be properly registered with the server 2. To resolve this, you should: - Ensure you're running Prefect server version 3.1.8 or greater - Check that your PREFECT_RUNNER_HEARTBEAT_FREQUENCY is set to an appropriate value (greater than 30 seconds) - Verify that the flow runs are properly registered with your self-hosted server - Consider adding a small delay to your automation trigger to ensure the flow run still exists when the action is executed 3. You can also try to: - Check the server logs for additional error messages - Verify that your server API endpoint is correctly configured - Confirm that the automation has the necessary permissions to modify flow run states Could you share: 1. What version of Prefect are you running on both the server and client side? 2. How long is the delay you've set in the trigger before it attempts to cancel the flow? This information would help me provide more specific guidance for your setup.
b
@Marvin I am running version 3.4.1. I have not set a delay. Only that it should be in a certain state for 2 minutes. Then it tries to change the state with the action. From the server side i see the following when trying to suspend a flow: 070442.801 | WARNING | prefect.server.events.actions - Action failed: "Unexpected status from 'suspend-flow-run' action: 404"
m
thought for 94.3 seconds
Based on the additional information you've provided and the research, I can offer a more specific diagnosis: 1. The 404 error suggests that when the automation tries to suspend/cancel the flow run after the 2-minute period, it cannot find the necessary endpoint or resource. This could be happening because: - The flow run's infrastructure might be terminating or becoming unavailable before the automation can execute - There might be a race condition between the state check and the action execution - The flow run might be transitioning to a different state during the automation attempt 2. To troubleshoot this, I recommend: a. First, add a small buffer delay to your automation to ensure stability: - Instead of just checking for "in state for 2 minutes" - Add a "delay" of 5-10 seconds before executing the action - This gives the system time to stabilize and ensure all resources are available b. Check your server logs for any additional error messages around the time of the automation trigger, particularly looking for: - Infrastructure-related messages - State transition messages - Any API endpoint issues c. Verify that your flow runs are using appropriate infrastructure that supports cancellation/suspension 3. Could you try to: - Modify the automation to include a small delay (5-10 seconds) before the action - Check if the issue persists with a longer "in state" duration (e.g., 3 minutes instead of 2) - Verify if this happens with all flow runs or only specific ones Could you also confirm: 1. Are you seeing this behavior consistently with all flow runs? 2. What infrastructure are you using for your flow runs (e.g., ProcessInfrastructure, DockerContainer, etc.)? 3. Can you manually suspend/cancel these flow runs through the UI when this happens? This information would help narrow down whether this is an infrastructure-specific issue or a more general automation timing problem.