BUG: Fix workflow run jobs API returning null steps#36603
BUG: Fix workflow run jobs API returning null steps#36603silverwind merged 6 commits intogo-gitea:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the Actions workflow run jobs API (GET /api/v1/repos/{owner}/{repo}/actions/runs/{runId}/jobs) so that job steps are populated instead of always being null, aligning the response with the underlying action_task_step data.
Changes:
- Load task steps in
convert.ToActionWorkflowJobviaGetTaskStepsByTaskIDwhen a job has an associated task. - Add an integration test asserting the jobs list endpoint returns non-null/non-empty
stepsfor a job with stored task steps.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| services/convert/convert.go | Loads task steps before converting a workflow job so API responses can include steps. |
| tests/integration/api_actions_run_test.go | Adds an integration test that inserts a task step and validates steps are returned by the jobs list endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When listing jobs via GET .../actions/runs/{run}/jobs, steps were always
null because ToActionWorkflowJob loaded the task by ID but never populated
task.Steps (xorm:"-"). Now we load steps via GetTaskStepsByTaskID so the
API returns step information for each job.
f45be0c to
50024e2
Compare
|
Review of this PR (this comment was written by Claude Code / claude-opus-4-6): The core fix is correct. The nil-task guard is a good improvement. The old code didn't check the One pre-existing issue worth noting (not introduced by this PR): The step status conversion uses Test looks good. It directly inserts a step for a fixture task and verifies the API returns non-null, non-empty steps with the correct data. Using |
* origin/main: (2555 commits) automate updating nix flakes (go-gitea#35641) Update AGENTS.md instructions (go-gitea#36627) use user id in noreply emails (go-gitea#36550) feat(db): Improve BuildCaseInsensitiveLike with lowercase (go-gitea#36598) [skip ci] Updated translations via Crowdin BUG: Fix workflow run jobs API returning null steps (go-gitea#36603) Refactor highlight and diff (go-gitea#36599) Fix bug when do LFS GC (go-gitea#36500) feature to be able to filter project boards by milestones (go-gitea#36321) Update emoji data for Unicode 16 (go-gitea#36596) Adapt monaco error matching pattern to recent webpack config change (go-gitea#36533) Fix a bug user could change another user's primary email (go-gitea#36586) fix(repo-editor): disable Monaco `editContext` to avoid bugs with lost focus (go-gitea#36585) Fine tune diff highlighting (go-gitea#36592) Add code editor setting dropdowns (go-gitea#36534) Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588) Improve diff highlighting (go-gitea#36583) Fix markup code block layout (go-gitea#36578) Remove striped tables in UI (go-gitea#36509) Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570) ... # Conflicts: # custom/conf/app.example.ini # docs/content/administration/config-cheat-sheet.en-us.md # docs/content/administration/config-cheat-sheet.zh-cn.md # modules/setting/security.go # routers/common/errpage.go # services/context/api.go # services/context/context.go
## Problem
`GET /api/v1/repos/{owner}/{repo}/actions/runs/{runId}/jobs` was always
returning `steps: null` for each job.
## Cause
In `convert.ToActionWorkflowJob`, when the job had a `TaskID` we loaded
the task with `db.GetByID` but never loaded `task.Steps`.
`ActionTask.Steps` is not stored in the task row (`xorm:"-"`); it comes
from `action_task_step` and is only filled by `task.LoadAttributes()` /
`GetTaskStepsByTaskID()`. So the conversion loop over `task.Steps`
always saw nil and produced no steps in the API response.
## Solution
After resolving the task (by ID when the caller passes `nil`), we now
load its steps with `GetTaskStepsByTaskID(ctx, task.ID)` and set
`task.Steps` before building the API steps slice. No other behavior is
changed.
## Testing
- New integration test `TestAPIListWorkflowRunJobsReturnsSteps`: calls
the runs/{runId}/jobs endpoint, inserts a task step for a fixture job,
and asserts that the response includes non-null, non-empty `steps` with
the expected step data.
- `make test-sqlite#TestAPIListWorkflowRunJobsReturnsSteps` passes with
this fix.
---------
Co-authored-by: Manav <mdave0905@gmail.com>
Problem
GET /api/v1/repos/{owner}/{repo}/actions/runs/{runId}/jobswas always returningsteps: nullfor each job.Cause
In
convert.ToActionWorkflowJob, when the job had aTaskIDwe loaded the task withdb.GetByIDbut never loadedtask.Steps.ActionTask.Stepsis not stored in the task row (xorm:"-"); it comes fromaction_task_stepand is only filled bytask.LoadAttributes()/GetTaskStepsByTaskID(). So the conversion loop overtask.Stepsalways saw nil and produced no steps in the API response.Solution
After resolving the task (by ID when the caller passes
nil), we now load its steps withGetTaskStepsByTaskID(ctx, task.ID)and settask.Stepsbefore building the API steps slice. No other behavior is changed.Testing
TestAPIListWorkflowRunJobsReturnsSteps: calls the runs/{runId}/jobs endpoint, inserts a task step for a fixture job, and asserts that the response includes non-null, non-emptystepswith the expected step data.make test-sqlite#TestAPIListWorkflowRunJobsReturnsStepspasses with this fix.