Skip to content

bug: ag init --force crashes with DUPLICATE_KEY_NAME when admin key exists #3351

Description

@OneStepAt4time

Bug Report

Aegis version: v0.6.7-preview.1

Reproduction

  1. Run ag init — creates admin key "ag-init-admin"
  2. Run ag init --force

Expected

Either reuses the existing key or replaces it. --force should handle this.

Actual

Failed to start Aegis: Error: An API key with the name "ag-init-admin" already exists for this tenant
    at AuthManager.createKey (dist/services/auth/AuthManager.js:183:25)
    at handleInit (dist/commands/init.js:555:46)
  code: 'DUPLICATE_KEY_NAME',
  statusCode: 409

Impact

MEDIUM--force is the documented way to re-bootstrap, but it fails when any key from a previous init still exists.

Fix Suggestion

--force should either:

  1. Delete the existing key before creating a new one, or
  2. Reuse the existing key and just regenerate the config

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1P2backendbugSomething isn't workingreleasedIncluded in a published release

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions