AgentTaskFail fails one claimed task run after token verification.
(c *gin.Context)
| 260 | |
| 261 | // AgentTaskFail fails one claimed task run after token verification. |
| 262 | func (h *BaseHandlers) AgentTaskFail(c *gin.Context) { |
| 263 | manager, caller, runID, ok := h.agentTaskLeaseMutationSetup(c, agentTaskActionFail) |
| 264 | if !ok { |
| 265 | return |
| 266 | } |
| 267 | |
| 268 | var req contract.AgentTaskFailRequest |
| 269 | if err := c.ShouldBindJSON(&req); err != nil { |
| 270 | h.respondError( |
| 271 | c, |
| 272 | http.StatusBadRequest, |
| 273 | NewTaskValidationError(fmt.Errorf("%s: decode agent task fail request: %w", h.transportName(), err)), |
| 274 | ) |
| 275 | return |
| 276 | } |
| 277 | |
| 278 | failure, err := failTaskRunFromRequest(contract.FailTaskRunRequest(req)) |
| 279 | if err != nil { |
| 280 | h.respondError(c, statusForAgentTaskError(err), err) |
| 281 | return |
| 282 | } |
| 283 | handle, err := h.lookupAgentTaskLease(c.Request.Context(), manager, caller, runID) |
| 284 | if err != nil { |
| 285 | h.respondError(c, statusForAgentTaskError(err), err) |
| 286 | return |
| 287 | } |
| 288 | run, err := manager.FailRunLease(c.Request.Context(), taskpkg.LeaseFailure{ |
| 289 | RunID: runID, |
| 290 | ClaimToken: handle.ClaimToken, |
| 291 | Failure: failure, |
| 292 | }, caller.Actor) |
| 293 | if err != nil { |
| 294 | h.respondError(c, statusForAgentTaskError(err), err) |
| 295 | return |
| 296 | } |
| 297 | |
| 298 | c.JSON(http.StatusOK, contract.AgentTaskLeaseResponse{Lease: AgentTaskLeasePayloadFromRun(run, nil)}) |
| 299 | } |
| 300 | |
| 301 | func (h *BaseHandlers) agentTaskLeaseMutationSetup( |
| 302 | c *gin.Context, |
nothing calls this directly
no test coverage detected