Skip to content

Commit 628dd68

Browse files
committed
Fix job logs endpoint: use job ID instead of job index
The GetWorkflowJobLogs endpoint was incorrectly using DownloadActionsRunJobLogsWithIndex which expects a job index (0, 1, 2...) but we were passing a job ID (192). Fixed by: - Using GetRunJobByID to get the job by its actual ID - Using DownloadActionsRunJobLogs instead of the index-based version - Adding validation that the job belongs to the specified run This resolves the 404 'Job logs not found' error in CI tests.
1 parent 1788cfa commit 628dd68

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

routers/api/v1/repo/actions_run.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,23 @@ func GetWorkflowJobLogs(ctx *context.APIContext) {
682682

683683
jobID := ctx.PathParamInt64("job_id")
684684

685-
if err = common.DownloadActionsRunJobLogsWithIndex(ctx.Base, ctx.Repo.Repository, runID, jobID); err != nil {
685+
// Get the job by ID and verify it belongs to the run
686+
job, err := actions_model.GetRunJobByID(ctx, jobID)
687+
if err != nil {
688+
ctx.APIErrorInternal(err)
689+
return
690+
}
691+
if job.RunID != runID {
692+
ctx.APIError(404, "Job not found in this run")
693+
return
694+
}
695+
696+
if err = job.LoadRepo(ctx); err != nil {
697+
ctx.APIErrorInternal(err)
698+
return
699+
}
700+
701+
if err = common.DownloadActionsRunJobLogs(ctx.Base, ctx.Repo.Repository, job); err != nil {
686702
if errors.Is(err, util.ErrNotExist) {
687703
ctx.APIError(404, "Job logs not found")
688704
} else {

0 commit comments

Comments
 (0)