-
Previous Value Current Value Title: Running a job from a stale branch file view silently submits an outdated commit
Running a job from a stale branch file view silently submits an outdated commit
-
State changed as build OD-8358 is successful
-
OneDev
changed state to 'Closed' 2 weeks ago
Previous Value Current Value Open
Closed
-
| Type |
Bug
|
| Priority |
Normal
|
| Assignee | |
| Affected Versions |
16.5.7
|
| Labels |
No labels
|
Issue Votes (0)
We encountered an unexpected and potentially dangerous behavior when manually
running a job from the project Files page.
We are using OneDev 16.5.7.
A user had the Files page for the
masterbranch open in a browser tab. Whilethe tab remained open, several newer commits were pushed to
master. About20 minutes later, the user manually started a deployment job from the build
status dropdown on that page without refreshing it.
At that time,
masterpointed to:However, the resulting build used:
The older commit
01b0b91was the commit displayed when the browser page had originally been loaded.There was no indication in the job dropdown or confirmation flow that the job would run against an outdated commit rather than the current head of
master.This caused our deployment job to deploy an older Helm configuration and prune Kubernetes resources that had been introduced by the newer commits. We have restored the affected deployment, but the same behavior could cause more serious service or data loss for deployment jobs.
How to reproduce
The job appears to use the commit resolved when the Files page was loaded, while still recording the branch as its ref.
We understand that OneDev intentionally supports running jobs for historical commits. However, when starting a job from a branch view, we would expect either the current branch head to be used or a clear warning that the branch has moved and the job will run against an older commit.
Could you please confirm whether this behavior is intended? If it is, we believe the commit being executed should be clearly shown before the job is submitted.
For reference, we had a brief look at the OneDev 16.5.7 source code. In
ProjectBlobPage, the branch revision appears to be resolved and stored asresolvedRevisionwhen the page is created. This captured object ID is later passed toCommitStatusLink, then toRunJobLink, which submits it ascommitIdtogether with the branchrefName.Relevant locations:
ProjectBlobPage.java: branch resolution https://github.com/theonedev/onedev/blob/v16.5.7/server-core/src/main/java/io/onedev/server/web/page/project/blob/ProjectBlobPage.java#L234-L239ProjectBlobPage.java: construction ofCommitStatusLinkhttps://github.com/theonedev/onedev/blob/v16.5.7/server-core/src/main/java/io/onedev/server/web/page/project/blob/ProjectBlobPage.java#L904-L913RunJobLink.java: submission using the capturedcommitIdandrefNamehttps://github.com/theonedev/onedev/blob/v16.5.7/server-core/src/main/java/io/onedev/server/web/component/job/RunJobLink.java#L156-L158This seems consistent with the behavior we observed: the page retains the commit resolved at page-load time even though the branch ref has subsequently advanced. We also compared these areas with the current
mainbranch and did not notice a relevant change.Thanks in advance!
Best regards, Alex