{"record":{"id":"f6e473419f632ded","repo":"semaphoreui/semaphore","slug":"sshkey-does-not-exist-in-keys-name","errorCode":null,"errorMessage":"SSHKey does not exist in keys[].Name","messagePattern":"SSHKey does not exist in keys\\[\\]\\.Name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/restore.go","lineNumber":174,"sourceCode":"\t\t}\n\t\tkey.SourceStorageID = &sourceStorage.ID\n\t}\n\n\tnewKey, err := b.store.CreateAccessKey(key)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tb.keys = append(b.keys, newKey)\n\treturn nil\n}\n\nfunc (e BackupInventory) Verify(backup *BackupFormat) error {\n\tif err := verifyDuplicate[BackupInventory](e.Name, backup.Inventories); err != nil {\n\t\treturn err\n\t}\n\tif e.SSHKey != nil && getEntryByName[BackupAccessKey](e.SSHKey, backup.Keys) == nil {\n\t\treturn fmt.Errorf(\"SSHKey does not exist in keys[].Name\")\n\t}\n\tif e.BecomeKey != nil && getEntryByName[BackupAccessKey](e.BecomeKey, backup.Keys) == nil {\n\t\treturn fmt.Errorf(\"BecomeKey does not exist in keys[].Name\")\n\t}\n\treturn nil\n}\n\nfunc (e BackupInventory) Restore(b *BackupDB) error {\n\tvar SSHKeyID *int\n\tif e.SSHKey == nil {\n\t\tSSHKeyID = nil\n\t} else if k := findEntityByName[db.AccessKey](e.SSHKey, b.keys); k == nil {\n\t\tSSHKeyID = nil\n\t} else {\n\t\tSSHKeyID = &((*k).ID)\n\t}\n\tvar BecomeKeyID *int\n\tif e.BecomeKey == nil {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/restore.go#L156-L192","documentation":"BackupInventory.Verify checks that an inventory's optional SSHKey reference names an existing entry in the backup's keys[] (access keys). If the named key is absent, verification fails with this error before restore, catching dangling key references early.","triggerScenarios":"Calling BackupFormat.Verify (or restore preflight) on a backup where inventory.ssh_key names an access key missing from keys[].name — key deleted, renamed, or omitted from the export.","commonSituations":"Partial backups that skipped access keys; renamed keys after export; hand-edited backups; inventories copied between projects referencing keys from another project.","solutions":["Add an access-key entry with that name to keys[] in the backup.","Point inventory.ssh_key at an existing keys[].name entry.","Set ssh_key to null if the inventory does not need an SSH key.","Run Verify on the whole backup and fix all dangling key references before restoring."],"exampleFix":"// before\n\"ssh_key\": \"deploy-key\", \"keys\": []\n// after\n\"keys\": [{\"name\": \"deploy-key\", ...}]","handlingStrategy":"validation","validationCode":"func inventorySSHKeyExists(b BackupFormat) error {\n    for _, inv := range b.Inventories {\n        if inv.SSHKey != nil && getEntryByName[BackupAccessKey](*inv.SSHKey, b.Keys) == nil {\n            return fmt.Errorf(\"inventory %q references missing ssh_key %q\", inv.Name, *inv.SSHKey)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := backup.Verify(); err != nil {\n    if strings.Contains(err.Error(), \"SSHKey does not exist\") {\n        // add the key or null the ssh_key reference, then retry\n    }\n    return err\n}","preventionTips":["Export access keys together with inventories that reference them.","Update inventory references when renaming or deleting keys.","Automate a Verify step before every restore."],"tags":["backup-restore","validation","missing-reference"],"backgroundTag":"resource-not-found","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"}