Skip to content

Commit

Permalink
Merge pull request #115 from PrefectHQ/run_fix
Browse files Browse the repository at this point in the history
Properly check for agent id before updating flow run agent
  • Loading branch information
cicdw authored Oct 23, 2020
2 parents c821f35 + 721cc91 commit 946f2a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changes/issue114.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- "Check for existence of agent before updating flow run agent - [#114](https://github.com/PrefectHQ/server/issues/114)"
7 changes: 6 additions & 1 deletion src/prefect_server/api/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ async def delete_flow_run(flow_run_id: str) -> bool:


@register_api("runs.update_flow_run_agent")
async def update_flow_run_agent(flow_run_id: str, agent_id: str) -> None:
async def update_flow_run_agent(flow_run_id: str, agent_id: str) -> bool:
"""
Updates the agent instance of a flow run
Expand All @@ -406,6 +406,11 @@ async def update_flow_run_agent(flow_run_id: str, agent_id: str) -> None:
Returns:
bool: if the update was successful
"""

agent = await models.Agent.where(id=agent_id).first()
if not agent:
return False

result = await models.FlowRun.where(id=flow_run_id).update(
set={"agent_id": agent_id}
)
Expand Down

0 comments on commit 946f2a9

Please sign in to comment.