Skip to content

fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs#37288

Merged
silverwind merged 5 commits intogo-gitea:mainfrom
KalashThakare:fix/37252-schedule-event-api-trigger-event
Apr 21, 2026
Merged

fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs#37288
silverwind merged 5 commits intogo-gitea:mainfrom
KalashThakare:fix/37252-schedule-event-api-trigger-event

Conversation

@KalashThakare
Copy link
Copy Markdown
Contributor

Summary

Fixes #37252

The /api/v1/repos/{owner}/{repo}/actions/runs endpoint was returning
event: "push" for workflow runs triggered by schedule: (cron), instead
of event: "schedule".

Root Cause

ActionRun has two separate fields:

  • Event — the workflow registration event (e.g. push, set when the workflow file was first pushed)
  • TriggerEvent — the actual event that triggered the run (e.g. schedule)

ToActionWorkflowRun in services/convert/action.go was serializing
run.Event into the API response instead of run.TriggerEvent, causing
scheduled runs to be indistinguishable from push events via the API.

This was already asymmetric — the tasks/jobs API correctly used TriggerEvent.

Fix

Changed ToActionWorkflowRun to use run.TriggerEvent for the event
field in the API response, consistent with how the jobs API works.

Before

event: "push" returned for all scheduled runs:

Screenshot 2026-04-19 115642

After

event: "schedule" correctly returned for scheduled runs:

Screenshot 2026-04-19 121723

Testing

  • Added unit test TestToActionWorkflowRun_UsesTriggerEvent in
    services/convert/action_test.go that explicitly verifies the API
    returns TriggerEvent and not Event for a scheduled run.
  • Manually verified via the API against a live Gitea instance with a
    cron: "* * * * *" workflow.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 19, 2026
@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 19, 2026

To make it more clear should we publish both via api?

@KalashThakare
Copy link
Copy Markdown
Contributor Author

To make it more clear should we publish both via api?

yes i think we should as it will eventually help consumers get more context.

@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 19, 2026

and maybe also have a look how github behaves here - especially for api its good to have nearly the same

@KalashThakare
Copy link
Copy Markdown
Contributor Author

and maybe also have a look how github behaves here - especially for api its good to have nearly the same

ok i will look into it.

@silverwind
Copy link
Copy Markdown
Member

silverwind commented Apr 19, 2026

Two minor items worth addressing:

  1. Redundant assertion in services/convert/action_test.goassert.NotEqual(t, string(run.Event), apiRun.Event) adds nothing once the preceding assert.Equal(t, "schedule", apiRun.Event) holds with run.Event = "push". Safe to drop.

  2. Integration coverage gap — this bug slipped past tests/integration/workflow_run_api_check_test.go because every existing action_run fixture has event == trigger_event. Adding a scheduled-run fixture where the two differ would guard against regression at the API layer, not just the converter.


This comment was written by Claude Opus 4.7.

@lunny lunny removed the modifies/go label Apr 19, 2026
@KalashThakare
Copy link
Copy Markdown
Contributor Author

and maybe also have a look how github behaves here - especially for api its good to have nearly the same

Github only exposes event field( actual event that triggered the run )

@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 Apr 21, 2026
@lunny lunny added type/bug backport/v1.26 This PR should be backported to Gitea 1.26 labels Apr 21, 2026
@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 21, 2026

Two minor items worth addressing:

  1. Redundant assertion in services/convert/action_test.goassert.NotEqual(t, string(run.Event), apiRun.Event) adds nothing once the preceding assert.Equal(t, "schedule", apiRun.Event) holds with run.Event = "push". Safe to drop.

  2. Integration coverage gap — this bug slipped past tests/integration/workflow_run_api_check_test.go because every existing action_run fixture has event == trigger_event. Adding a scheduled-run fixture where the two differ would guard against regression at the API layer, not just the converter.


This comment was written by Claude Opus 4.7.

Did you address them?

@bircni bircni added this to the 1.26.1 milestone Apr 21, 2026
@bircni bircni requested a review from lunny April 21, 2026 19:30
@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 21, 2026
@bircni bircni requested a review from silverwind April 21, 2026 19:30
@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 21, 2026

@silverwind addressed your requests

Comment thread services/convert/action_test.go
@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 Apr 21, 2026
@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 Apr 21, 2026
@silverwind silverwind enabled auto-merge (squash) April 21, 2026 20:07
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 21, 2026
@silverwind silverwind merged commit c69cbb7 into go-gitea:main Apr 21, 2026
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 21, 2026
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Apr 22, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 22, 2026
* main: (25 commits)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  Fix bug when accessing user badges (go-gitea#37321)
  Fix AppFullLink (go-gitea#37325)
  Update go js dependencies (go-gitea#37312)
  Update GitHub Actions to latest major versions (go-gitea#37313)
  Revert "Add WebKit to e2e test matrix (go-gitea#37298)" (go-gitea#37315)
  Add `form-fetch-action` to some forms, fix "fetch action" resp bug (go-gitea#37305)
  Move heatmap to first-party code (go-gitea#37262)
  ...
silverwind pushed a commit that referenced this pull request Apr 22, 2026
…for scheduled runs (#37288) (#37360)

Backport #37288 by @KalashThakare

## Summary

Fixes #37252

The `/api/v1/repos/{owner}/{repo}/actions/runs` endpoint was returning
`event: "push"` for workflow runs triggered by `schedule:` (cron),
instead
of `event: "schedule"`.

## Root Cause

`ActionRun` has two separate fields:
- `Event` — the workflow registration event (e.g. `push`, set when the
workflow file was first pushed)
- `TriggerEvent` — the actual event that triggered the run (e.g.
`schedule`)

`ToActionWorkflowRun` in `services/convert/action.go` was serializing
`run.Event` into the API response instead of `run.TriggerEvent`, causing
scheduled runs to be indistinguishable from push events via the API.

This was already asymmetric — the tasks/jobs API correctly used
`TriggerEvent`.

## Fix

Changed `ToActionWorkflowRun` to use `run.TriggerEvent` for the `event`
field in the API response, consistent with how the jobs API works.

## Before

`event: "push"` returned for all scheduled runs:

<img width="1112" height="191" alt="Screenshot 2026-04-19 115642"
src="https://github.com/user-attachments/assets/c0a169f5-bbd9-4f5d-9474-e4c3795110e4"
/>

## After

`event: "schedule"` correctly returned for scheduled runs:

<img width="890" height="166" alt="Screenshot 2026-04-19 121723"
src="https://github.com/user-attachments/assets/860e99ac-0935-4a43-86a1-7b60f8113480"
/>


## Testing

- Added unit test `TestToActionWorkflowRun_UsesTriggerEvent` in
  `services/convert/action_test.go` that explicitly verifies the API
  returns `TriggerEvent` and not `Event` for a scheduled run.
- Manually verified via the API against a live Gitea instance with a
  `cron: "* * * * *"` workflow.

Co-authored-by: Kalash Thakare ☯︎ <kalashthakare898@gmail.com>
Co-authored-by: Nicolas <bircni@icloud.com>
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 23, 2026
* origin/main: (32 commits)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  ...

# Conflicts:
#	services/actions/commit_status.go
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 23, 2026
* origin/main: (204 commits)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  ...

# Conflicts:
#	web_src/js/index-domready.ts
#	web_src/js/markup/content.ts
#	web_src/js/markup/refissue.ts
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 23, 2026
* origin/main: (204 commits)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  ...

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>

# Conflicts:
#	web_src/js/index-domready.ts
#	web_src/js/markup/content.ts
#	web_src/js/markup/refissue.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.26 This PR should be backported to Gitea 1.26 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: /actions/runs returns event: "push" for scheduled workflow runs

5 participants