diff --git a/models/fixtures/action_run_job.yml b/models/fixtures/action_run_job.yml index 9455ac3c41..00f9998ba9 100644 --- a/models/fixtures/action_run_job.yml +++ b/models/fixtures/action_run_job.yml @@ -128,3 +128,18 @@ runs_on: '["fedora"]' started: 1683636528 stopped: 1683636626 +- + id: 396 + run_id: 794 + repo_id: 4 + owner_id: 1 + commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee + is_fork_pull_request: 0 + name: job_2 + attempt: 1 + job_id: job_2 + task_id: null + status: 5 + runs_on: '["fedora"]' + started: 1683636528 + stopped: 1683636626 diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index d9255aaa55..b5e73e9d33 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -336,6 +336,11 @@ func getViewResponse(ctx *context_module.Context, req *ViewRequest, runIndex, jo } var task *actions_model.ActionTask + // TaskID will be set only when the ActionRunJob has been picked by a runner, resulting in an ActionTask being + // created representing the specific task. If current.TaskID is not set, then the user is attempting to view a job + // that hasn't been picked up by a runner... in this case we're not going to try to fetch the specific attempt. + // This helps to support the UI displaying a useful and error-free page when viewing a job that is queued but not + // picked, or an attempt that is queued for rerun but not yet picked. if current.TaskID > 0 { var err error task, err = actions_model.GetTaskByJobAttempt(ctx, current.ID, attemptNumber) @@ -357,6 +362,7 @@ func getViewResponse(ctx *context_module.Context, req *ViewRequest, runIndex, jo } resp.State.CurrentJob.Steps = make([]*ViewJobStep, 0) // marshal to '[]' instead of 'null' in json resp.Logs.StepsLog = make([]*ViewStepLog, 0) // marshal to '[]' instead of 'null' in json + // As noted above with TaskID; task will be nil when the job hasn't be picked yet... if task != nil { taskAttempts, err := task.GetAllAttempts(ctx) if err != nil { @@ -452,6 +458,12 @@ func getViewResponse(ctx *context_module.Context, req *ViewRequest, runIndex, jo return resp } +// When used with the JS `linkAction` handler (typically a