phacility/phabricator · error · PhabricatorApplicationTransactionValidationException

Another namespace with this name already exists. Each namesp

Error message

Another namespace with this name already exists. Each namespace must have a unique name.

What it means

Thrown by PhabricatorRepository::assertValidRepositorySlug() when a repository short name does not end with a letter or number. Trailing separators are rejected to avoid accidental double separators when the slug is joined into URIs or paths and to keep clone URLs clean. It is raised from the preg_match('/[a-zA-Z0-9]\z/', $slug) check when the short-name transaction applies a value ending in '.', '-', or '_'.

Source

Thrown at src/applications/almanac/editor/AlmanacNamespaceEditor.php:46

    return $types;
  }

  protected function didCatchDuplicateKeyException(
    PhabricatorLiskDAO $object,
    array $xactions,
    Exception $ex) {

    $errors = array();

    $errors[] = new PhabricatorApplicationTransactionValidationError(
      null,
      pht('Invalid'),
      pht(
        'Another namespace with this name already exists. Each namespace '.
        'must have a unique name.'),
      null);

    throw new PhabricatorApplicationTransactionValidationException($errors);
  }

}

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Trim trailing separators from the name: rtrim($slug, '._-').
  2. Review generated slugs after character replacement and length truncation, since both can leave a dangling separator.
  3. Pre-validate with PhabricatorRepository::isValidRepositorySlug().

Example fix

// before
$slug = preg_replace('/[^a-zA-Z0-9._-]/', '-', 'widget (dev)'); // 'widget--dev-'

// after
$slug = rtrim(preg_replace('/[^a-zA-Z0-9._-]+/', '-', 'widget (dev)'), '._-'); // 'widget-dev'
Defensive patterns

Strategy: type-guard

Validate before calling

$slug = rtrim($slug, '._-');

Type guard

function isValidShortName($slug) {
  return PhabricatorRepository::isValidRepositorySlug((string)$slug);
}

Try / catch

try {
  PhabricatorRepository::assertValidRepositorySlug($slug);
} catch (Exception $ex) {
  // strip trailing separators and revalidate, or reject
}

Prevention

When it happens

Trigger: Setting a short name like 'utils-' or 'repo.': the end-anchor regex at PhabricatorRepository.php:403 finds no trailing letter/digit and throws.

Common situations: Sanitizer pipelines that replace invalid runs with hyphens but never trim the tail ('widget (dev)' -> 'widget-dev-'); names truncated mid-separator by length limits; copy-paste trailing punctuation.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/48f0afe7fd6cce3a. Report an issue: GitHub.