{"record":{"id":"2f2fd2bed01729bf","repo":"semaphoreui/semaphore","slug":"error-at-roles-d-s","errorCode":null,"errorMessage":"error at roles[%d]: %s","messagePattern":"error at roles\\[(.+?)\\]: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/restore.go","lineNumber":578,"sourceCode":"\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 {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at roles[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Runners {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at runners[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\tfor i, o := range backup.Workflows {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at workflows[%d]: %s\", i, err.Error())\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (backup *BackupFormat) Restore(user db.User, store db.Store, workflowStore db.WorkflowManager) (*db.Project, error) {\n\tvar b = BackupDB{store: store, workflowStore: workflowStore}","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/restore.go#L560-L596","documentation":"This error wraps a per-item failure from BackupFormat.Verify() while validating backup.Roles: the project role at index i failed o.Verify(backup). A role entry in the backup is invalid (bad name, permissions, or duplicate), so the backup fails validation and cannot be restored.","triggerScenarios":"Calling BackupFormat.Verify() where the role at backup.Roles[i] fails Verify — e.g. empty role name, invalid permission bitmask, or a duplicate role in the backup.","commonSituations":"Custom roles created on the source instance conflicting with the target's built-in roles; hand-edited backups; schema changes to role definitions across Semaphore versions.","solutions":["Read the inner error after 'roles[i]:' to identify the failing role field","Fix or remove the role entry at the reported index in the backup file","Check the role name does not collide with built-in or duplicate roles","Re-export the backup from the source instance if the roles section was hand-built"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for i, r := range backup.Roles {\n    if r == nil || r.Name == \"\" {\n        return fmt.Errorf(\"roles[%d]: missing name before restore\", i)\n    }\n}\nif err := backup.Verify(); err != nil {\n    return err\n}","typeGuard":"func validRole(r *RoleBackup) bool { return r != nil && r.Name != \"\" }","tryCatchPattern":"if err := backup.Verify(); err != nil {\n    if strings.Contains(err.Error(), \"roles[\") {\n        // fix or drop the role at the reported index\n    }\n    return err\n}","preventionTips":["Avoid role names colliding with built-in roles","Run Verify() before Restore","Don't hand-craft role entries; export them from the source instance"],"tags":["backup","validation","roles","restore"],"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"}