hashicorp/vault · warning · Error

A record already exists with the name: ${name}

Error message

A record already exists with the name: ${name}

What it means

Thrown by the named-path adapter (ui/app/adapters/named-path.js:34) used for Vault resources whose ID is a user-chosen name. The Vault HTTP API upserts on POST for these endpoints, so creating a record with an existing name would silently overwrite it. The adapter guards against this by peeking the Ember store for the name before delegating to _saveRecord().

Source

Thrown at ui/app/adapters/named-path.js:34

  _saveRecord(store, { modelName }, snapshot) {
    // since the response is empty return the serialized data rather than nothing
    const data = store.serializerFor(modelName).serialize(snapshot);
    const primaryKey = store.serializerFor(modelName).primaryKey;
    return this.ajax(this.urlForUpdateRecord(snapshot.attr('name'), modelName, snapshot), this.saveMethod, {
      data,
    }).then(() => {
      data[primaryKey] = snapshot.attr(primaryKey);
      return data;
    });
  }

  // create does not return response similar to PUT request
  createRecord() {
    const [store, { modelName }, snapshot] = arguments;
    const name = snapshot.attr('name');
    // throw error if user attempts to create a record with same name, otherwise POST request silently overrides (updates) the existing model
    if (store.peekRecord({ type: modelName, id: name }) !== null) {
      throw new Error(`A record already exists with the name: ${name}`);
    } else {
      return this._saveRecord(...arguments);
    }
  }

  // update uses same endpoint and method as create
  updateRecord() {
    return this._saveRecord(...arguments);
  }

  // if backend does not return name in response Ember Data will throw an error for pushing a record with no id
  // use the id (name) supplied to findRecord to set property on response data
  findRecord(store, type, name) {
    return super.findRecord(...arguments).then((resp) => {
      if (!resp.data.name) {
        resp.data.name = name;
      }
      return resp;

View on GitHub (pinned to 744b611b57)

Solutions

  1. Choose a different, unique name for the new record
  2. Reload the parent list so the store cache reflects what actually exists, then retry
  3. If you meant to modify the existing item, edit it instead of creating a new one

Example fix

// before
const record = this.store.createRecord('pki/role', { name });
await record.save();

// after
if (this.store.peekRecord('pki/role', name)) {
  this.flash.warning(`"${name}" already exists — edit it instead of creating a new one.`);
} else {
  const record = this.store.createRecord('pki/role', { name });
  await record.save();
}
Defensive patterns

Strategy: validation

Validate before calling

// Check for the name before creating — mirror the adapter's own guard at the caller
const existing = store.peekRecord(modelName, name);
if (existing) {
  // route the user to edit instead of silently overwriting via POST
  this.router.transitionTo('edit-route', existing);
} else {
  await this._saveRecord(...);
}

Try / catch

try {
  await record.save();
} catch (e) {
  if (e.message.startsWith('A record already exists with the name:')) {
    notifyUser('Name taken — edit the existing record or pick another name');
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: store.createRecord(...).save() (POST /v1/<named-path>) when store.peekRecord({type: modelName, id: name}) already finds a record with the same name in the local store cache — typically because the item is visible in the current list or was loaded earlier in the session.

Common situations: User submits a create form with a name that is already in the list (duplicate tab, stale list after another admin added the same name); tests that do not reset the Ember store between runs; the browser back button resubmitting a create form.

Related errors


AI-assisted analysis of hashicorp/vault@744b611b57 (2026-08-15). Data as JSON: /api/errors/9c335d51f409ee3d. Report an issue: GitHub.