Skip to content

Fix scheduled action panic with null event payload#37459

Merged
silverwind merged 8 commits intogo-gitea:mainfrom
cyphercodes:fix/actions-schedule-null-payload
Apr 28, 2026
Merged

Fix scheduled action panic with null event payload#37459
silverwind merged 8 commits intogo-gitea:mainfrom
cyphercodes:fix/actions-schedule-null-payload

Conversation

@cyphercodes
Copy link
Copy Markdown
Contributor

@cyphercodes cyphercodes commented Apr 27, 2026

This fixes the scheduled action panic when an event payload is JSON null by initializing the payload map before adding schedule. It also adds regression coverage for the null-payload case.

Fixes #37447.

Testing:

  • go test -tags 'sqlite sqlite_unlock_notify' ./services/actions -run '^TestWithScheduleInEventPayload$' -count=1
    • Local note: this agent ran the command as root with a temporary GITEA_TEST_CONF=custom/conf/app-test-root.ini file that only set I_AM_BEING_UNSAFE_RUNNING_AS_ROOT = true.

Authorship: cyphercodes; AI assistance disclosed: Hermes Agent (GPT-5.5).

Avoid assigning to a nil map when a scheduled action event payload is JSON null.

Co-Authored-By: Hermes Agent (GPT-5.5) <hermes-agent@users.noreply.github.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 27, 2026
@wxiaoguang wxiaoguang added the backport/v1.26 This PR should be backported to Gitea 1.26 label Apr 27, 2026
@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 27, 2026
Comment thread services/actions/schedule_tasks.go Outdated
@bircni bircni requested a review from wxiaoguang April 27, 2026 20:01
@cyphercodes
Copy link
Copy Markdown
Contributor Author

Rechecked wxiaoguang's inline feedback against current HEAD fd2ab90dfc1c67b73846550816b38793af4b24c7. The current diff already treats eventPayload == "" as an empty payload/map and includes the regression test for that case, so I did not push another commit.

Local verification:

  • Created temporary root-test config custom/conf/hermes-root-test.ini with I_AM_BEING_UNSAFE_RUNNING_AS_ROOT = true, then ran GITEA_TEST_CONF=custom/conf/hermes-root-test.ini PATH=/root/sdk/go1.26.2/bin:$PATH go test -tags 'sqlite sqlite_unlock_notify' -run '^TestWithScheduleInEventPayload$' ./services/actions/
  • PATH=/root/sdk/go1.26.2/bin:$PATH gofmt -l services/actions/schedule_tasks.go services/actions/schedule_tasks_test.go ✅ (no output)
  • git diff --check upstream/main...HEAD

Authored-by: Hermes Agent (GPT-5.5)

@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 27, 2026

Rechecked wxiaoguang's inline feedback against current HEAD fd2ab90dfc1c67b73846550816b38793af4b24c7. The current diff already treats eventPayload == "" as an empty payload/map and includes the regression test for that case, so I did not push another commit.

Yes as I did it 👀

@silverwind silverwind added topic/gitea-actions related to the actions of Gitea type/bug labels Apr 28, 2026
Use a single `var event map[string]any` declaration instead of
initialising twice, and add a comment explaining where the empty/null
eventPayload values come from (addresses wxiaoguang's review note).

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@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 28, 2026
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 28, 2026
@silverwind silverwind added reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Apr 28, 2026
@silverwind
Copy link
Copy Markdown
Member

Test failure is unrelated

@silverwind silverwind enabled auto-merge (squash) April 28, 2026 01:11
@silverwind silverwind merged commit c8e6779 into go-gitea:main Apr 28, 2026
26 checks passed
@GiteaBot GiteaBot added this to the 1.27.0 milestone Apr 28, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 28, 2026
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Apr 28, 2026
wxiaoguang pushed a commit that referenced this pull request Apr 28, 2026
Backport #37459 by cyphercodes

This fixes the scheduled action panic when an event payload is JSON
`null` by initializing the payload map before adding `schedule`. It also
adds regression coverage for the null-payload case.

Fixes #37447.

Co-authored-by: Rayan Salhab <r.salhab@aiyexpertsolutions.com>
Co-authored-by: cyphercodes <cyphercodes@users.noreply.github.com>
Co-authored-by: Hermes Agent (GPT-5.5) <hermes-agent@users.noreply.github.com>
Co-authored-by: Nicolas <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 29, 2026
* main:
  Add DEFAULT_TITLE_SOURCE setting for pull request title default behavior (go-gitea#37465)
  Fix compare dropdown for branches without common history (go-gitea#37470)
  FIX: URL sanitization to handle schemeless credentials (go-gitea#37440)
  Refactor pull request view (4) (go-gitea#37451)
  Fix scheduled action panic with null event payload (go-gitea#37459)
  Fix attachment Content-Security-Policy (go-gitea#37455)
  [skip ci] Updated translations via Crowdin
  Rename CurrentRefPath to CurrentRefSubURL (go-gitea#37453)
  Clean up org pages layout (go-gitea#37445)
  Fix script error alert (go-gitea#37458)
  Fix inconsistent disabled styling on logged-out repo header buttons (go-gitea#37406)
  Add API endpoint to reply to pull request review comments (go-gitea#36683)
  Add CurrentURL template variable back (go-gitea#37444)
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. topic/gitea-actions related to the actions of Gitea type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Actions withScheduleInEventPayload PANIC

6 participants