semaphoreui/semaphore · error

view does not exist in views[].name

Error message

view does not exist in views[].name

What it means

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.

Solutions

  1. Add the view with that name to backup.Views.
  2. Update the template's view field to an existing views[].name.
  3. Set the template's view reference to null if no view is needed.

Example fix

// before
"templates": [{"name": "build", "view": "ops-view"}], "views": []
// after
"templates": [{"name": "build", "view": "ops-view"}], "views": [{"name": "ops-view"}]
Defensive patterns

Strategy: validation

Validate before calling

if t.View != nil && !viewNameExists(*t.View, backup.Views) {
  return fmt.Errorf("template %q references missing view %q", t.Name, *t.View)
}

Type guard

func viewNameExists(name string, views []BackupView) bool {
  for _, v := range views {
    if v.Name == name { return true }
  }
  return false
}

Try / catch

if err := tmpl.Verify(backup); err != nil {
  if strings.Contains(err.Error(), "view does not exist") {
    // include the view or clear the reference
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: UI reorganizations where views were renamed; selective exports including templates but not views; backups restored into a different project that lacks the view.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at services/project/restore.go:271

		return fmt.Errorf("inventory does not exist in inventories[].name")
	}

	if e.VaultKey != nil && getEntryByName[BackupAccessKey](e.VaultKey, backup.Keys) == nil {
		return fmt.Errorf("vault_key does not exist in keys[].name")
	}

	if e.Vaults != nil {
		for _, vault := range e.Vaults {
			if vault.VaultKey != nil {
				if getEntryByName[BackupAccessKey](vault.VaultKey, backup.Keys) == nil {
					return fmt.Errorf("vaults[].vaultKey does not exist in keys[].name")
				}
			}
		}
	}

	if e.View != nil && getEntryByName[BackupView](e.View, backup.Views) == nil {
		return fmt.Errorf("view does not exist in views[].name")
	}

	if buildTemplate := getEntryByName[BackupTemplate](e.BuildTemplate, backup.Templates); string(e.Type) == "deploy" && buildTemplate == nil {
		return fmt.Errorf("deploy is build but build_template does not exist in templates[].name")
	}

	return nil
}

func (e BackupTemplate) Restore(b *BackupDB) error {
	var InventoryID *int
	if e.Inventory != nil {
		if k := findEntityByName[db.Inventory](e.Inventory, b.inventories); k == nil {
			return fmt.Errorf("inventory does not exist in inventories[].name")
		} else {
			id := k.GetID()
			InventoryID = &id
		}

View on GitHub (pinned to 1774ccb71a)