{"record":{"id":"a038077423aaf3b5","repo":"semaphoreui/semaphore","slug":"item-d-does-not-exist","errorCode":null,"errorMessage":"item %d does not exist","messagePattern":"item (.+?) does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/backup.go","lineNumber":29,"sourceCode":"\nfunc findNameBySlug[T db.BackupSluggedEntity](slug string, items []T) (*string, error) {\n\tfor _, o := range items {\n\t\tif o.GetSlug() == slug {\n\t\t\tname := o.GetName()\n\t\t\treturn &name, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"item %s does not exist\", slug)\n}\n\nfunc findNameByID[T db.BackupEntity](ID int, items []T) (*string, error) {\n\tfor _, o := range items {\n\t\tif o.GetID() == ID {\n\t\t\tname := o.GetName()\n\t\t\treturn &name, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"item %d does not exist\", ID)\n}\n\nfunc findEntityByName[T db.BackupEntity](name *string, items []T) *T {\n\tif name == nil {\n\t\treturn nil\n\t}\n\tfor _, o := range items {\n\t\tif o.GetName() == *name {\n\t\t\treturn &o\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc getSchedulesByProject(projectID int, schedules []db.Schedule) []db.Schedule {\n\tresult := make([]db.Schedule, 0)\n\tfor _, o := range schedules {\n\t\tif o.ProjectID == projectID {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/backup.go#L11-L47","documentation":"findNameByID in services/project/backup.go:29 scans the given entity list comparing each GetID() to the requested numeric ID and returns \"item %d does not exist\" when nothing matches. It is used during backup formatting to resolve entity IDs from a backup file to names.","triggerScenarios":"format() processes a backup that references an entity by numeric ID (e.g. schedule template ID, repository ID) that is absent from the supplied list of that entity type in the database.","commonSituations":"Restoring a backup taken from another instance where auto-increment IDs differ; referencing an entity that was deleted after the backup was made; backup produced with a database dump of only part of the project's entities.","solutions":["Look up which entity type and ID the backup references and confirm it exists in the target database (SELECT by id).","Recreate the missing entity so its ID matches, or update the backup file to point at an existing ID.","Re-export the backup with all referenced entities included.","If IDs cannot match across instances, restore into the original instance or edit references to use names/slugs instead of IDs."],"exampleFix":"// before\n\"template_id\": 42  // no template with ID 42 in target DB\n// after\n\"template_id\": 17  // ID of an existing template in the target DB","handlingStrategy":"validation","validationCode":"ids := map[int]bool{}\nfor _, it := range items { ids[it.GetID()] = true }\nif !ids[id] { return fmt.Errorf(\"backup references missing entity ID %d\", id) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer name/slug references over raw IDs in backups; IDs differ across instances.","Check target DB for referenced IDs before restoring a backup from another instance.","Never delete entities that are still referenced by stored backups."],"tags":["go","backup","restore","id-not-found"],"backgroundTag":"record-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"}