{"record":{"id":"a5200c97a3ac52fe","repo":"semaphoreui/semaphore","slug":"item-s-does-not-exist","errorCode":null,"errorMessage":"item %s does not exist","messagePattern":"item (.+?) does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/backup.go","lineNumber":19,"sourceCode":"package project\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"reflect\"\n\n\t\"github.com/semaphoreui/semaphore/db\"\n\t\"github.com/semaphoreui/semaphore/pkg/random\"\n)\n\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 {","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/backup.go#L1-L37","documentation":"findNameBySlug in services/project/backup.go:19 does a linear scan of a list of backup entities, matching each one's GetSlug() against the requested slug. If no item matches, it returns \"item %s does not exist\". This is part of project backup/restore formatting, where backup JSON references entities by slug and the code maps a slug back to a human-readable name.","triggerScenarios":"Calling format (project backup formatting) with a backup file that references an entity slug (e.g. a repository, environment, or inventory slug) that is not present in the current database's list of entities for that project.","commonSituations":"Restoring a backup into a different Semaphore instance where the referenced repository/environment/inventory was deleted or renamed; slug case mismatch (slugs are compared exactly); the backup was exported from a project whose related entities were not included in the export.","solutions":["Check the slug in the backup file against the existing entities (GET /inventory, /environment, /repository endpoints) and recreate the missing entity or fix the slug.","Re-export the backup including all referenced entities so slugs resolve.","Verify slug spelling and case in the backup JSON exactly matches the live entity's slug.","Delete or null out the stale slug reference in the backup JSON before restoring."],"exampleFix":"// before (backup JSON references slug that does not exist)\n{\"repository_slug\": \"prod-repo\"}\n// after\n# create the repository with slug \"prod-repo\" in the target project, or edit the backup:\n{\"repository_slug\": \"actual-repo-slug\"}","handlingStrategy":"validation","validationCode":"slugs := map[string]bool{}\nfor _, it := range items { slugs[it.GetSlug()] = true }\nif !slugs[slug] { return fmt.Errorf(\"backup references missing entity slug %q\", slug) }","typeGuard":"func slugExists(slug string, items []db.BackupSluggedEntity) bool {\n    for _, it := range items {\n        if it.GetSlug() == slug { return true }\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always export backups including all referenced entities (repositories, inventories, environments).","Validate backup JSON references against the target DB before restoring.","Keep slugs stable; avoid renaming entities between export and restore."],"tags":["go","backup","restore","slug-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"}