Skip to content

BUG: Fix workflow run jobs API returning null steps#36603

Merged
silverwind merged 6 commits intogo-gitea:mainfrom
bircni:bugfix/api-job-null-returns
Feb 13, 2026
Merged

BUG: Fix workflow run jobs API returning null steps#36603
silverwind merged 6 commits intogo-gitea:mainfrom
bircni:bugfix/api-job-null-returns

Conversation

@bircni
Copy link
Copy Markdown
Member

@bircni bircni commented Feb 12, 2026

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.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 12, 2026
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Feb 12, 2026
@silverwind silverwind requested a review from Copilot February 12, 2026 18:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ToActionWorkflowJob via GetTaskStepsByTaskID when a job has an associated task.
  • Add an integration test asserting the jobs list endpoint returns non-null/non-empty steps for 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.

bircni and others added 3 commits February 12, 2026 20:27
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.
@bircni bircni force-pushed the bugfix/api-job-null-returns branch from f45be0c to 50024e2 Compare February 12, 2026 19:27
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 12, 2026
@silverwind
Copy link
Copy Markdown
Member

Review of this PR (this comment was written by Claude Code / claude-opus-4-6):

The core fix is correct. ActionTask.Steps is tagged xorm:"-" and lives in the action_task_step table, so db.GetByID never populates it. Explicitly calling GetTaskStepsByTaskID after resolving the task is the right approach, and the if task.Steps == nil guard is consistent with the same pattern used in ActionTask.LoadAttributes (models/actions/task.go:137).

The nil-task guard is a good improvement. The old code didn't check the has return from db.GetByID, so if the task row was somehow missing, it would dereference a zero-value ActionTask. Wrapping the runner/steps logic in if task != nil prevents that.

One pre-existing issue worth noting (not introduced by this PR): The step status conversion uses ToActionsStatus(job.Status) for every step, meaning all steps inherit the job-level status/conclusion rather than their own individual step.Status. Since ActionTaskStep has its own Status field (used elsewhere, e.g. in Duration()), this should probably be ToActionsStatus(step.Status). This is out of scope for this PR but might be worth a follow-up fix.

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 t.Context() is fine given the go 1.26 requirement in go.mod.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 13, 2026
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 13, 2026
@silverwind silverwind enabled auto-merge (squash) February 13, 2026 07:12
@silverwind silverwind merged commit afcd11c into go-gitea:main Feb 13, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 13, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 13, 2026
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 14, 2026
* 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
@bircni bircni deleted the bugfix/api-job-null-returns branch February 27, 2026 20:20
Sirherobrine23 pushed a commit to Sirherobrine23/gitea that referenced this pull request Mar 4, 2026
## 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>
@bircni bircni mentioned this pull request Mar 22, 2026
lunny pushed a commit that referenced this pull request Mar 22, 2026
I'd like to apply as a maintainer.

Thanks to @TheFox0x7 for the suggestion.

Merged PRs:
- #36441
- #36571
- #36603
- #36768
- #36776
- #36783
- #36876
- #36883
- #36924

Ongoing work:
- #36514
- #36752
- #36912
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants