{"record":{"id":"4b3988ffcbfcc58d","repo":"semaphoreui/semaphore","slug":"err-4b3988","errorCode":null,"errorMessage":"err","messagePattern":"err","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/cmd/vault_check.go","lineNumber":51,"sourceCode":"\t\t}\n\n\t\tcounts := map[string]int{} // key id (\"\" = legacy/no prefix) -> row count\n\t\tvar total, missing int\n\n\t\terr := eachLocalAccessKey(store, func(key db.AccessKey) error {\n\t\t\tif key.Secret == nil || *key.Secret == \"\" {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\ttotal++\n\t\t\tid := util.SecretKeyID(*key.Secret) // \"\" for legacy un-prefixed values\n\t\t\tcounts[id]++\n\t\t\tif id != \"\" && !util.Config.HasKeyID(id) {\n\t\t\t\tmissing++\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tfmt.Printf(\"Access keys: %d total\\n\", total)\n\n\t\t// Report every key id seen in the database, plus keyset keys with no rows.\n\t\tids := map[string]struct{}{}\n\t\tfor id := range counts {\n\t\t\tids[id] = struct{}{}\n\t\t}\n\t\tfor _, id := range util.Config.KeyIDs() {\n\t\t\tids[id] = struct{}{}\n\t\t}\n\t\tsorted := make([]string, 0, len(ids))\n\t\tfor id := range ids {\n\t\t\tsorted = append(sorted, id)\n\t\t}\n\t\tsort.Strings(sorted)\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/cli/cmd/vault_check.go#L33-L69","documentation":"In `vault check`, the panic fires when the read-only walk over all locally encrypted access keys (`eachLocalAccessKey` -> project/access-key store queries) returns an error. The command is meant to report key usage; a database failure during enumeration aborts the whole check. The panic message is generic — the wrapped DB error matters.","triggerScenarios":"Running `semaphore vault check` while `store.GetAllProjects()` or any `store.GetAccessKeys(...)` page query fails: database down, permission denied, or schema mismatch.","commonSituations":"Database credentials/connection issues in config; CLI run against a database from a newer/older Semaphore version; read-only DB user missing SELECT grants on projects/access_key tables.","solutions":["Verify database connectivity and grants for the configured user.","Rerun after confirming the Semaphore schema is migrated to the CLI's version.","Inspect the wrapped error in the stack trace for the failing table/query and fix at the DB level.","Run `semaphore vault check` on a database snapshot locally to separate DB issues from key issues."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if err := store.GetAllProjects(); err != nil {\n    // abort check early with a clear message instead of walking keys\n}","typeGuard":null,"tryCatchPattern":"if err := eachLocalAccessKey(store, fn); err != nil {\n    fmt.Fprintf(os.Stderr, \"vault check aborted: %v\\n\", err)\n    os.Exit(1)\n}","preventionTips":["Ensure the DB user has SELECT on projects and access_key tables.","Keep the CLI binary and database schema on the same version (run migrations first).","Test `vault check` against a restored backup before running on production."],"tags":["cli","database","vault","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"}