kubero-dev / kubero-dev/kubero

Race condition in form.vue causes "domain already taken" error when editing existing apps

Open Beginner friendly
#738 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.4k
Forks
213
PR merge metrics
No merged PRs in 30d

Description

## Bug Report

### Problem

Editing any existing Kubero app in the UI shows a "domain already taken" error and the Save button is disabled, even though the domain belongs to the app being edited.

### Root Cause

Race condition in `client/src/components/apps/form.vue`. In `mounted()`, `getDomains()` and `loadPipelineAndApp()` run concurrently via `Promise.all`. Inside `loadPipelineAndApp()`, `loadApp()` is called but **not awaited**, so `getDomains()` resolves first. When it calls `whiteListDomains()`, `this.ingress.hosts` is still empty — the app's own domain is never excluded from `takenDomains`. The backend enforces no domain uniqueness; this is purely a frontend bug.

This was introduced in PR #265 (v2.0.0, Jan 2024).

Additionally, `whiteListDomains()` has a splice index bug that makes it unreliable even when called in the correct order (mutating an array while iterating by index).

### Steps to Reproduce

1. Create an app with a custom domain
2. Navigate to the app edit page
3. Observe: the domain field shows "already taken" and Save is disabled

### Fix

**1. Make `loadApp()` async:**
```js
async loadApp() {
if (this.app !== "new") {
return axios.get(`/api/apps/${this.pipeline}/${this.phase}/${this.app}`)
.then((response) => {
// populate this.ingress — whiteListDomains call removed
});
}
},
```

**2. Await `loadApp()` inside `loadPipelineAndApp()`:**
```js
if (this.app != "new") {
await this.loadApp();
}
```

**3. Fix `whiteListDomains()` splice bug:**
```js
whiteListDomains(domainsList: string[]) {
const ownHosts = new Set(this.ingress.hosts.map((h) => h.host));
return domainsList.filter((d) => !ownHosts.has(d));
},
```

I will submit a PR with these fixes shortly.

Contributor guide

Open the contributing guide

Research direction

Start in client/src/components/apps/form.vue and trace mounted(), loadPipelineAndApp(), loadApp(), and whiteListDomains() during the app edit flow. Verify that the existing app's host is excluded from takenDomains after loading, that the domain error disappears, and that the Save button is enabled for the app's own domain.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.