semaphoreui/semaphore · error
template does not exist in templates[].name
Error message
template does not exist in templates[].name
What it means
BackupSchedule.Restore resolves the schedule's referenced template by name within the restored project's templates using findEntityByName. If no template with the referenced name exists in the backup's templates[] array, restore aborts with this error to avoid creating a schedule pointing at a nonexistent template.
Solutions
- Add a template entry with the exact missing name to templates[] in the backup.
- Rename the schedule's template reference to match an existing templates[].name entry.
- Remove or comment out the schedule if it is no longer needed.
- Re-export a full backup that includes both templates and schedules from the source project.
Example fix
// before
"schedules": [{"template": "nightly-build"}], "templates": []
// after
"templates": [{"name": "nightly-build", ...}], "schedules": [{"template": "nightly-build"}] Defensive patterns
Strategy: validation
Validate before calling
func scheduleTemplateExists(b BackupFormat) error {
for _, s := range b.Schedules {
if getEntryByName[BackupTemplate](s.Template, b.Templates) == nil {
return fmt.Errorf("schedule references missing template %q", s.Template)
}
}
return nil
} Try / catch
if err := backup.Verify(); err != nil {
if strings.Contains(err.Error(), "template does not exist") {
// add the template or fix the schedule reference, then retry
}
return err
} Prevention
- Always export full project backups including templates and schedules together.
- Run Verify before Restore in CI/CD pipelines.
- Update schedule references whenever templates are renamed or deleted.
When it happens
Trigger: Restoring a project backup where a schedule's template name does not match any entry in templates[].name — e.g. the template was deleted, renamed, or the backup arrays were edited separately.
Common situations: Partial backups that omitted templates[]; renamed templates after export; cross-project restores where the schedule references a template from another project; manual JSON cleanup removing a 'unused' template still referenced by a schedule.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- repo does not exist in repositories[].name
- secret storage does not exist in secret_storage[].name
- SSHKey does not exist in keys[].Name
- BecomeKey does not exist in keys[].Name
- expected array for slice, got %T
AI-assisted analysis of semaphoreui/semaphore@1774ccb71a (2026-09-07).
Data as JSON: /api/errors/188751a30d04a39e.
Report an issue: GitHub.
Appendix: source
Thrown at services/project/restore.go:107
newView, err := b.store.CreateView(v)
if err != nil {
return err
}
b.views = append(b.views, newView)
return nil
}
func (e BackupSchedule) Verify(backup *BackupFormat) error {
return verifyDuplicate[BackupSchedule](e.Name, backup.Schedules)
}
func (e BackupSchedule) Restore(b *BackupDB) error {
v := e.Schedule
v.ProjectID = b.meta.ID
tpl := findEntityByName[db.Template](&e.Template, b.templates)
if tpl == nil {
return fmt.Errorf("template does not exist in templates[].name")
}
v.TemplateID = tpl.ID
if e.CheckableRepository != nil {
repo := findEntityByName[db.Repository](e.CheckableRepository, b.repositories)
if repo == nil {
return fmt.Errorf("repo does not exist in repositories[].name")
}
v.RepositoryID = &repo.ID
}
if e.TaskParams != nil {
inv := findEntityByName[db.Inventory](e.TaskParams.InventoryName, b.inventories)
if inv != nil {
v.TaskParams.InventoryID = &inv.ID
}
}
View on GitHub (pinned to 1774ccb71a)