{"record":{"id":"cd2ad1c1341441a5","repo":"semaphoreui/semaphore","slug":"error-at-repositories-d-s","errorCode":null,"errorMessage":"error at repositories[%d]: %s","messagePattern":"error at repositories\\[(.+?)\\]: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/restore.go","lineNumber":558,"sourceCode":"\t}\n\tfor i, o := range backup.Views {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at views[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Schedules {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at templates[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Keys {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at keys[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Repositories {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at repositories[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Inventories {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at inventories[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.SecretStorages {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at secret storage[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Templates {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at templates[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Roles {","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/restore.go#L540-L576","documentation":"This error wraps a per-item failure from BackupFormat.Verify() while validating backup.Repositories: the repository object at index i failed o.Verify(backup). The backup's repositories section is inconsistent (bad fields or cross-references) and restore is refused before any DB writes happen.","triggerScenarios":"Calling BackupFormat.Verify() where the repository at backup.Repositories[i] fails Verify — e.g. empty repository name, missing/unknown SSH key reference, or invalid URL for the repository.","commonSituations":"Backups exported from another Semaphore instance with repository settings not representable in the target version; manually merged backups where a repo references a key that was dropped; corrupted YAML/JSON in the repository section.","solutions":["Inspect the inner error after 'repositories[i]:' for the exact field problem","Fix the repository entry at that index in the backup file (name, url, ssh key reference)","Verify referenced keys exist earlier in the same backup (repositories are verified after keys)","Re-export the backup from the source instance rather than editing it by hand"],"exampleFix":"// before\n\"repositories\": [{\"name\": \"repo\", \"ssh_key_id\": 42}]\n// after\n\"repositories\": [{\"name\": \"repo\", \"url\": \"git@github.com:org/repo.git\", \"ssh_key_name\": \"deploy-key\"}]","handlingStrategy":"validation","validationCode":"for i, r := range backup.Repositories {\n    if r == nil || r.Name == \"\" || r.URL == \"\" {\n        return fmt.Errorf(\"repositories[%d]: missing name/url before restore\", i)\n    }\n}\nif err := backup.Verify(); err != nil {\n    return err\n}","typeGuard":"func validRepository(r *RepositoryBackup) bool { return r != nil && r.Name != \"\" }","tryCatchPattern":"if err := backup.Verify(); err != nil {\n    if strings.Contains(err.Error(), \"repositories[\") {\n        // parse index and fix that repository entry\n    }\n    return err\n}","preventionTips":["Verify referenced keys exist before repositories in the backup","Run backup.Verify() before Restore","Re-export backups instead of editing them manually"],"tags":["backup","validation","restore","go"],"backgroundTag":"schema-validation-failed","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"}