semaphoreui/semaphore · error

no admins found in database; create a admin first

Error message

no admins found in database; create a admin first

What it means

resolveImportUser resolves which user to import a project as; it fetches all users and returns users[0]. When the database contains zero users it sets err to 'no admins found in database; create a admin first', aborting the import because there is no owner to assign the project to.

Solutions

  1. Create an admin first: `semaphore user add --login admin --name Admin --email admin@example.com --password ... --admin`
  2. Verify the config points to the intended database (check the users table has rows)
  3. Re-run the import after the user exists

Example fix

// before
semaphore project import project.json   # empty DB
// after
semaphore user add --login admin --name Admin --email admin@example.com --password '***' --admin
semaphore project import project.json
Defensive patterns

Strategy: validation

Validate before calling

if ! semaphore user list | grep -q .; then
  semaphore user add --login admin --name Admin --email admin@example.com --password "$PW" --admin
fi
semaphore project import project.json

Prevention

When it happens

Trigger: Running `semaphore project import` (or the import flow calling resolveImportUser) against a fresh/empty database where store.GetUsers returns an empty slice.

Common situations: Pointing the import CLI at a brand-new instance before any user registered; importing into a database that was migrated but never had an admin created via `semaphore user add`; wrong config pointing at an empty/other database.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of semaphoreui/semaphore@1774ccb71a (2026-09-07). Data as JSON: /api/errors/cea8e2af247493e5. Report an issue: GitHub.

Appendix: source

Thrown at cli/cmd/project_import.go:137

}

func resolveImportUser(store db.Store) (res db.User, err error) {
	admins, err := store.GetAllAdmins()
	if err != nil {
		return
	}

	if len(admins) > 0 {
		res = admins[0]
		return
	}
	users, err := store.GetUsers(db.RetrieveQueryParams{})
	if err != nil {
		return
	}

	if len(users) == 0 {
		err = errors.New("no admins found in database; create a admin first")
		return
	}

	res = users[0]
	return
}

func importProjectFromFile(path string, projectName string, user db.User, store db.Store) error {
	data, err := os.ReadFile(path)
	if err != nil {
		return err
	}
	var backup projectService.BackupFormat
	if err := backup.Unmarshal(string(data)); err != nil {
		return err
	}
	if err := backup.Verify(); err != nil {
		return err

View on GitHub (pinned to 1774ccb71a)