Which component(s) is affected?
Kubero UI
Describe the bug
When editing an existing app that is configured to use a non-default branch (e.g. develop), the branch input field shows the repository's default branch (e.g. main) instead of the previously configured branch. If the user clicks "Save" without noticing, the app's branch is silently changed to the default — causing it to deploy from the wrong branch.
Steps to reproduce
- Create a pipeline connected to a git repository with multiple branches (e.g.
main, develop)
- Create an app and set the branch to a non-default branch (e.g.
develop)
- Save the app
- Navigate back to edit the same app
- Observe: The branch field shows
main (the default branch) instead of develop
- Click "Save" without changing anything
- Result: The app's branch is now changed to
main
Expected behavior
When editing an existing app, the branch field should show the branch that was previously configured and saved.
Screenshots
No response
Additional information
Root Cause
The bug is a race condition in client/src/components/apps/form.vue between two unawaited async calls in loadPipelineAndApp() (line 1928):
- Line 1936:
this.loadBranches() fires an async HTTP request to /api/repo/.../branches (NOT awaited)
- Line 2004:
this.loadApp() fires an async HTTP request to /api/apps/... (NOT awaited)
Both .then() callbacks assign this.branch:
loadApp() (line 2141) correctly sets this.branch = response.data.spec.branch (the saved value, e.g. "develop")
loadBranches() (lines 2037–2042) unconditionally overwrites this.branch with pipelineData.git.repository.default_branch (e.g. "main")
Since loadBranches() calls an external git provider API (GitHub/GitLab/etc.), it is typically slower than loadApp() (which hits the local Kubernetes API). So the usual execution order is:
loadApp() resolves first → sets this.branch = "develop" ✅
loadBranches() resolves second → overwrites this.branch = "main" ❌
Suggested Fix
Guard the branch assignment in loadBranches() so it only pre-selects a default branch when creating a new app:
// In loadBranches(), lines 2036-2042:
if (this.app == "new") {
let defaultBranch = this.pipelineData.git.repository.default_branch;
if (this.branchesList.includes(defaultBranch)) {
this.branch = defaultBranch;
} else {
this.branch = this.branchesList[0];
}
}
This ensures loadBranches() still populates the branchesList dropdown (needed for both create and edit), but only pre-selects a branch value during app creation. During edit, loadApp() retains the final say on this.branch.
Additional Context
- The server side correctly stores and returns
spec.branch from the KuberoApp CRD — no issue there
- The kubero-operator (Helm-based) passes
spec.branch through to deployment templates without modification — no issue there
- The bug is purely a frontend race condition
Debug information
No response
Which component(s) is affected?
Kubero UI
Describe the bug
When editing an existing app that is configured to use a non-default branch (e.g.
develop), the branch input field shows the repository's default branch (e.g.main) instead of the previously configured branch. If the user clicks "Save" without noticing, the app's branch is silently changed to the default — causing it to deploy from the wrong branch.Steps to reproduce
main,develop)develop)main(the default branch) instead ofdevelopmainExpected behavior
When editing an existing app, the branch field should show the branch that was previously configured and saved.
Screenshots
No response
Additional information
Root Cause
The bug is a race condition in
client/src/components/apps/form.vuebetween two unawaited async calls inloadPipelineAndApp()(line 1928):this.loadBranches()fires an async HTTP request to/api/repo/.../branches(NOT awaited)this.loadApp()fires an async HTTP request to/api/apps/...(NOT awaited)Both
.then()callbacks assignthis.branch:loadApp()(line 2141) correctly setsthis.branch = response.data.spec.branch(the saved value, e.g."develop")loadBranches()(lines 2037–2042) unconditionally overwritesthis.branchwithpipelineData.git.repository.default_branch(e.g."main")Since
loadBranches()calls an external git provider API (GitHub/GitLab/etc.), it is typically slower thanloadApp()(which hits the local Kubernetes API). So the usual execution order is:loadApp()resolves first → setsthis.branch = "develop"✅loadBranches()resolves second → overwritesthis.branch = "main"❌Suggested Fix
Guard the branch assignment in
loadBranches()so it only pre-selects a default branch when creating a new app:This ensures
loadBranches()still populates thebranchesListdropdown (needed for both create and edit), but only pre-selects a branch value during app creation. During edit,loadApp()retains the final say onthis.branch.Additional Context
spec.branchfrom the KuberoApp CRD — no issue therespec.branchthrough to deployment templates without modification — no issue thereDebug information
No response