Skip to content

Replace index with id in actions routes#36842

Merged
silverwind merged 15 commits intogo-gitea:mainfrom
Zettat123:update-actions-route
Mar 10, 2026
Merged

Replace index with id in actions routes#36842
silverwind merged 15 commits intogo-gitea:mainfrom
Zettat123:update-actions-route

Conversation

@Zettat123
Copy link
Contributor

@Zettat123 Zettat123 commented Mar 6, 2026

This PR migrates the web Actions run/job routes from index-based runIndex or jobIndex to database IDs.

⚠️ BREAKING ⚠️: Existing saved links/bookmarks that use the old index-based URLs will no longer resolve after this change.

Improvements of this change:

  • Previously, jobIndex depended on list order, making it hard to locate a specific job. Using jobID provides stable addressing.
  • Web routes now align with API, which already use IDs.
  • Behavior is closer to GitHub, which exposes run/job IDs in URLs.
  • Provides a cleaner base for future features without relying on list order.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 6, 2026
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/frontend labels Mar 6, 2026
@Zettat123 Zettat123 added the topic/gitea-actions related to the actions of Gitea label Mar 6, 2026
@Zettat123 Zettat123 added the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label Mar 6, 2026
@Zettat123 Zettat123 force-pushed the update-actions-route branch from d8bab42 to 7106d44 Compare March 6, 2026 17:30
@wxiaoguang wxiaoguang removed the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label Mar 6, 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 Mar 7, 2026
Copy link
Contributor

@bircni bircni left a comment

Choose a reason for hiding this comment

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

Cool

Copy link
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

Migrates the repository web UI Actions run/job routes from index-based identifiers (runIndex/jobIndex) to stable database IDs (runID/jobID), aligning the web routes with the API and enabling more reliable addressing (especially with reusable workflows/child jobs).

Changes:

  • Update frontend components/templates to pass and consume runId/jobId, and generate /actions/runs/{runID}/jobs/{jobID} links.
  • Update backend web handlers and helpers to resolve runs/jobs by repo+ID (and run+job ID) and adjust log/rerun/cancel/approve/delete endpoints accordingly.
  • Update and extend integration/unit tests to reflect ID-based URLs and add coverage for cross-repo run/job access protections.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web_src/js/features/repo-actions.ts Pass runId/jobId props into the Actions view Vue app.
web_src/js/components/WorkflowGraph.vue Switch “current job” selection and job links from index to job ID.
web_src/js/components/RepoActionView.vue Update API calls and UI links (jobs, logs, rerun) to use IDs.
templates/repo/actions/view_component.tmpl Replace data-run-index/data-job-index with data-run-id/data-job-id.
templates/repo/actions/view.tmpl Pass RunID/JobID into the view component instead of indexes.
templates/devtest/repo-action-view.tmpl Update devtest template wiring to use RunID/JobID.
routers/web/repo/actions/view.go Rework run/job resolution and all related endpoints (view/post/logs/rerun/cancel/approve/delete) to use IDs.
routers/web/devtest/mock_actions.go Update devtest mock handler data keys to RunID/JobID.
routers/common/actions.go Replace “download logs by job index” helper with “by job ID” helper.
routers/api/v1/repo/actions_run.go Scope job-log download lookup by repo+job ID.
routers/api/v1/repo/action.go Return Actions dispatch HTMLURL using run ID instead of run index.
services/convert/convert.go Update webhook/API conversion to emit job HTMLURL using job ID.
services/actions/rerun.go Ensure run attributes are loaded before rerun logic continues (needed for downstream usage).
services/actions/commit_status.go Update commit-status target URLs and parsing/lookup paths to use IDs.
models/actions/run.go Change ActionRun HTMLURL()/Link() to use run database ID.
models/actions/run_job.go Replace GetRunJobByID with repo/run-scoped getters; adjust UpdateRunJob reload path accordingly.
models/actions/task.go Ensure job loading and run-job updates are repo-scoped; include RepoID when updating jobs from tasks.
models/git/commit_status_test.go Update Actions target URL test fixture to the new /runs/{id}/jobs/{id}-style pattern.
tests/integration/repo_webhook_test.go Update expected webhook HTMLURL and UI endpoints to use run/job IDs.
tests/integration/api_actions_run_test.go Update job lookup helpers in API rerun tests to be run-scoped.
tests/integration/actions_rerun_test.go Update rerun endpoints to use run/job IDs.
tests/integration/actions_log_test.go Update log download paths to use run/job IDs derived from tasks.
tests/integration/actions_delete_run_test.go Resolve run ID from run number and update all URLs to use run/job IDs.
tests/integration/actions_concurrency_test.go Update approve/rerun/cancel/job rerun URLs to use IDs; adjust assertions accordingly.
tests/integration/actions_route_test.go New integration test validating repo scoping and 404 behavior for mismatched run/job IDs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Zettat123 and others added 2 commits March 8, 2026 12:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Zettat123 <zettat123@gmail.com>
@Zettat123
Copy link
Contributor Author

Since the legacy CommitStatus.TargetURL was generated based on runIndex and jobIndex, those URLs will become invalid after this change.

status := git_model.CommitStatus{
SHA: commitID,
TargetURL: fmt.Sprintf("%s/jobs/%d", run.Link(), index),
Description: description,
Context: ctxName,
CreatorID: creator.ID,
State: state,
}

I’ve added a migration to convert all legacy TargetURLs into id-based URLs. This migration also addresses the issue in #36842 (comment)

@silverwind
Copy link
Member

Review by Claude on behalf of @silverwind

  1. getRunJobsAndCurrentJob no longer sets .Run on jobs — The old getRunJobs had a for _, v := range jobs { v.Run = run } loop that's removed now. If any downstream code (e.g. convertToViewModel, CancelJobs) accesses job.Run on jobs from this list, it will be nil. Needs verification.

  2. approve returns 500 instead of 404 for cross-repo access — Every other cross-repo case in the new route test correctly expects 404, but approve expects 500. The approveRuns function doesn't distinguish util.ErrNotExist from internal errors inside its db.WithTx call. Should be 404 for consistency and to avoid leaking information.

  3. Migration cache inconsistency in getRunByIndexCached — First miss returns (nil, error), subsequent misses for the same key return (nil, nil) because nil is cached as the value. The caller handles both cases so it works, but it's surprising behavior.

@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 Mar 10, 2026
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 10, 2026
@silverwind silverwind merged commit 3859942 into go-gitea:main Mar 10, 2026
26 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Mar 10, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 10, 2026
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/api This PR adds API routes or modifies them modifies/frontend modifies/go Pull requests that update Go code modifies/migrations modifies/templates This PR modifies the template files topic/gitea-actions related to the actions of Gitea

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants