Skip to content

Commit

Permalink
Return StatusOk if task is already completed
Browse files Browse the repository at this point in the history
  • Loading branch information
avillega committed Mar 6, 2025
1 parent 5d42a86 commit 3a96170
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/app/coroutines/completeTask.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func CompleteTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any],
}

if t.State == task.Completed || t.State == task.Timedout {
status = t_api.StatusTaskAlreadyCompleted
status = t_api.StatusOK
} else if t.State == task.Init || t.State == task.Enqueued {
status = t_api.StatusTaskInvalidState
} else if t.Counter != r.CompleteTask.Counter {
Expand Down
4 changes: 2 additions & 2 deletions test/dst/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ func (v *Validator) ValidateCompleteTask(model *Model, reqTime int64, resTime in
model = model.Copy()
model.tasks.set(req.CompleteTask.Id, res.CompleteTask.Task)
return model, nil
case t_api.StatusTaskAlreadyCompleted:
case t_api.StatusOK:
if t == nil {
return model, fmt.Errorf("task '%s' does not exist", req.CompleteTask.Id)
}
Expand All @@ -700,7 +700,7 @@ func (v *Validator) ValidateCompleteTask(model *Model, reqTime int64, resTime in
IdempotencyKeyForComplete: p.IdempotencyKeyForComplete,
Tags: p.Tags,
CreatedOn: p.CreatedOn,
CompletedOn: &reqTime,
CompletedOn: util.ToPointer(p.Timeout),
SortId: p.SortId,
}
model.promises.set(p.Id, &newP)
Expand Down

0 comments on commit 3a96170

Please sign in to comment.