Skip to content

Commit 4ac892d

Browse files
committed
Check task id is zero
1 parent ba36164 commit 4ac892d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

routers/web/user/task.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ import (
1616

1717
// TaskStatus returns task's status
1818
func TaskStatus(ctx *context.Context) {
19-
task, _, err := admin_model.GetMigratingTaskByID(ctx, ctx.PathParamInt64("task"), 0)
19+
taskID := ctx.PathParamInt64("task")
20+
if taskID <= 0 {
21+
ctx.JSON(http.StatusBadRequest, map[string]any{
22+
"err": "invalid task ID",
23+
})
24+
return
25+
}
26+
task, _, err := admin_model.GetMigratingTaskByID(ctx, taskID, 0)
2027
if err != nil {
2128
if admin_model.IsErrTaskDoesNotExist(err) {
2229
ctx.JSON(http.StatusNotFound, map[string]any{

0 commit comments

Comments
 (0)