Skip to content

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

@JamesSprow

Description

@JamesSprow

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:

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():

if (this.app != "new") {
  await this.loadApp();
}

3. Fix whiteListDomains() splice bug:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions