{"record":{"id":"e146441a85399a73","repo":"semaphoreui/semaphore","slug":"err","errorCode":null,"errorMessage":"err","messagePattern":"err","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/cmd/user_totp.go","lineNumber":120,"sourceCode":"\t\t}\n\n\t\tstore := createStore(\"\")\n\t\tdefer store.Close()\n\n\t\tuser, err := store.GetUserByLoginOrEmail(targetUserArgs.login, \"\")\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tif user.Totp == nil {\n\t\t\tfmt.Println(\"TOTP not enabled\")\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\terr = store.DeleteTotpVerification(user.ID, user.Totp.ID)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t},\n}\n\nvar totpShowCmd = &cobra.Command{\n\tUse:   \"show\",\n\tShort: \"Show TOTP details\",\n\tRun: func(cmd *cobra.Command, args []string) {\n\t\tif targetUserArgs.login == \"\" {\n\t\t\tfmt.Println(\"Argument --login required\")\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tstore := createStore(\"\")\n\t\tdefer store.Close()\n\n\t\tuser, err := store.GetUserByLoginOrEmail(targetUserArgs.login, \"\")\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/cli/cmd/user_totp.go#L102-L138","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check database connectivity and credentials in the Semaphore config before rerunning the command.","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.","Inspect the full panic stack trace for the underlying store/SQL error and fix the reported DB issue (permissions, schema version, dialect).","Migrate the database (`semaphore migrate` / service upgrade) if the schema is out of date."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"user, err := store.GetUserByLoginOrEmail(login, \"\")\nif err != nil || user.Totp == nil {\n    // skip DeleteTotpVerification: user missing or TOTP already disabled\n    return\n}","typeGuard":"if user.Totp == nil {\n    fmt.Println(\"TOTP not enabled\")\n    return\n}","tryCatchPattern":"if err := store.DeleteTotpVerification(user.ID, user.Totp.ID); err != nil {\n    fmt.Fprintf(os.Stderr, \"delete TOTP failed: %v\\n\", err)\n    os.Exit(1)\n}","preventionTips":["Confirm TOTP is enabled before attempting removal (the command already exits early when Totp is nil).","Verify DB connectivity with a cheap query before batch TOTP operations.","Serialize admin operations on the same user to avoid delete-after-delete races."],"tags":["cli","database","totp","panic"],"backgroundTag":"database-query-failed","analyzedSha":"1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa","analyzedAt":"2026-09-07T11:00:33.293Z","contentChangedAt":"2026-09-07T11:00:33.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}