Manager: prevent error when fetching task that was never assigned

Prevent an error when fetching a task that was never assigned to a
worker.

The error:

```
WRN error fetching task worker
    error="fetching worker : worker not found: sql: no rows in result set"
```
This commit is contained in:
Sybren A. Stüvel 2025-01-09 14:45:28 +01:00
parent 234cfbf983
commit 8b322e84f8

View File

@ -138,6 +138,7 @@ func (f *Flamenco) FetchTask(e echo.Context, taskID string) error {
} }
apiTask := taskJobWorkertoAPI(taskJobWorker) apiTask := taskJobWorkertoAPI(taskJobWorker)
if taskJobWorker.WorkerUUID != "" {
// Fetch the worker. TODO: get rid of this conversion, just include the // Fetch the worker. TODO: get rid of this conversion, just include the
// worker's UUID and let the caller fetch the worker info themselves if // worker's UUID and let the caller fetch the worker info themselves if
// necessary. // necessary.
@ -147,6 +148,7 @@ func (f *Flamenco) FetchTask(e echo.Context, taskID string) error {
return sendAPIError(e, http.StatusInternalServerError, "error fetching task worker") return sendAPIError(e, http.StatusInternalServerError, "error fetching task worker")
} }
apiTask.Worker = workerToTaskWorker(taskWorker) apiTask.Worker = workerToTaskWorker(taskWorker)
}
// Fetch & convert the failure list. // Fetch & convert the failure list.
failedWorkers, err := f.persist.FetchTaskFailureList(ctx, &taskJobWorker.Task) failedWorkers, err := f.persist.FetchTaskFailureList(ctx, &taskJobWorker.Task)