semaphoreui/semaphore · error

err

Error message

err

What it means

This is the CLI's blanket `panic(err)` after `store.DeleteTotpVerification(user.ID, user.Totp.ID)` fails in `user totp remove`. Any database error returned by the store layer (connection failure, SQL error, row constraint) is propagated verbatim by crashing the process with a stack trace. The panic itself carries no semantic message — the wrapped database error is the real cause.

Solutions

  1. Check database connectivity and credentials in the Semaphore config before rerunning the command.
  2. Re-check that the user still exists and still has TOTP enabled (`semaphore user totp show --login <user>`); if the row is already gone, nothing needs deleting.
  3. Inspect the full panic stack trace for the underlying store/SQL error and fix the reported DB issue (permissions, schema version, dialect).
  4. Migrate the database (`semaphore migrate` / service upgrade) if the schema is out of date.
Defensive patterns

Strategy: validation

Validate before calling

user, err := store.GetUserByLoginOrEmail(login, "")
if err != nil || user.Totp == nil {
    // skip DeleteTotpVerification: user missing or TOTP already disabled
    return
}

Type guard

if user.Totp == nil {
    fmt.Println("TOTP not enabled")
    return
}

Try / catch

if err := store.DeleteTotpVerification(user.ID, user.Totp.ID); err != nil {
    fmt.Fprintf(os.Stderr, "delete TOTP failed: %v\n", err)
    os.Exit(1)
}

Prevention

When it happens

Trigger: Running `semaphore user totp remove --login <user>` where the user exists and has TOTP enabled, but the DELETE of the totp_verification row fails: database unreachable, SQL syntax/compat error, or the TOTP row was deleted between the fetch and the delete.

Common situations: Database server down or misconfigured in config.json; permissions on the totp_verification table revoked; two admins running TOTP removal concurrently so the row is already gone; unsupported DB dialect producing failing SQL.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at cli/cmd/user_totp.go:120

		}

		store := createStore("")
		defer store.Close()

		user, err := store.GetUserByLoginOrEmail(targetUserArgs.login, "")

		if err != nil {
			panic(err)
		}

		if user.Totp == nil {
			fmt.Println("TOTP not enabled")
			os.Exit(1)
		}

		err = store.DeleteTotpVerification(user.ID, user.Totp.ID)
		if err != nil {
			panic(err)
		}
	},
}

var totpShowCmd = &cobra.Command{
	Use:   "show",
	Short: "Show TOTP details",
	Run: func(cmd *cobra.Command, args []string) {
		if targetUserArgs.login == "" {
			fmt.Println("Argument --login required")
			os.Exit(1)
		}

		store := createStore("")
		defer store.Close()

		user, err := store.GetUserByLoginOrEmail(targetUserArgs.login, "")

View on GitHub (pinned to 1774ccb71a)