{"record":{"id":"72aff4567df583e0","repo":"semaphoreui/semaphore","slug":"view-does-not-exist-in-views-name","errorCode":null,"errorMessage":"view does not exist in views[].name","messagePattern":"view does not exist in views\\[\\]\\.name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/restore.go","lineNumber":271,"sourceCode":"\t\treturn fmt.Errorf(\"inventory does not exist in inventories[].name\")\n\t}\n\n\tif e.VaultKey != nil && getEntryByName[BackupAccessKey](e.VaultKey, backup.Keys) == nil {\n\t\treturn fmt.Errorf(\"vault_key does not exist in keys[].name\")\n\t}\n\n\tif e.Vaults != nil {\n\t\tfor _, vault := range e.Vaults {\n\t\t\tif vault.VaultKey != nil {\n\t\t\t\tif getEntryByName[BackupAccessKey](vault.VaultKey, backup.Keys) == nil {\n\t\t\t\t\treturn fmt.Errorf(\"vaults[].vaultKey does not exist in keys[].name\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif e.View != nil && getEntryByName[BackupView](e.View, backup.Views) == nil {\n\t\treturn fmt.Errorf(\"view does not exist in views[].name\")\n\t}\n\n\tif buildTemplate := getEntryByName[BackupTemplate](e.BuildTemplate, backup.Templates); string(e.Type) == \"deploy\" && buildTemplate == nil {\n\t\treturn fmt.Errorf(\"deploy is build but build_template does not exist in templates[].name\")\n\t}\n\n\treturn nil\n}\n\nfunc (e BackupTemplate) Restore(b *BackupDB) error {\n\tvar InventoryID *int\n\tif e.Inventory != nil {\n\t\tif k := findEntityByName[db.Inventory](e.Inventory, b.inventories); k == nil {\n\t\t\treturn fmt.Errorf(\"inventory does not exist in inventories[].name\")\n\t\t} else {\n\t\t\tid := k.GetID()\n\t\t\tInventoryID = &id\n\t\t}","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/restore.go#L253-L289","documentation":"Thrown by BackupTemplate.Verify when the optional View reference on a template names a view that is absent from backup.Views. Views are linked by name; the check ensures the restored template can resolve its view.","triggerScenarios":"Verify with e.View != nil and no BackupView of that name in backup.Views — view deleted or renamed after the backup, or views excluded from the export scope.","commonSituations":"UI reorganizations where views were renamed; selective exports including templates but not views; backups restored into a different project that lacks the view.","solutions":["Add the view with that name to backup.Views.","Update the template's view field to an existing views[].name.","Set the template's view reference to null if no view is needed."],"exampleFix":"// before\n\"templates\": [{\"name\": \"build\", \"view\": \"ops-view\"}], \"views\": []\n// after\n\"templates\": [{\"name\": \"build\", \"view\": \"ops-view\"}], \"views\": [{\"name\": \"ops-view\"}]","handlingStrategy":"validation","validationCode":"if t.View != nil && !viewNameExists(*t.View, backup.Views) {\n  return fmt.Errorf(\"template %q references missing view %q\", t.Name, *t.View)\n}","typeGuard":"func viewNameExists(name string, views []BackupView) bool {\n  for _, v := range views {\n    if v.Name == name { return true }\n  }\n  return false\n}","tryCatchPattern":"if err := tmpl.Verify(backup); err != nil {\n  if strings.Contains(err.Error(), \"view does not exist\") {\n    // include the view or clear the reference\n  }\n}","preventionTips":["Export views along with templates.","Update backups after view renames before restoring them.","Treat optional references as deletable: clear them if the view is gone."],"tags":["restore","backup","referential-integrity","view","go"],"backgroundTag":"entity-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"}