{"record":{"id":"194676929aef7f11","repo":"semaphoreui/semaphore","slug":"global-role-does-not-exist-s","errorCode":null,"errorMessage":"global role does not exist: %s","messagePattern":"global role does not exist: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/restore.go","lineNumber":368,"sourceCode":"\n\t\t\ttplVault := vault.TemplateVault\n\t\t\ttplVault.ProjectID = b.meta.ID\n\t\t\ttplVault.TemplateID = newTemplate.ID\n\t\t\ttplVault.VaultKeyID = VaultKeyID\n\n\t\t\t_, err := b.store.CreateTemplateVault(tplVault)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif e.Roles != nil {\n\t\tfor _, role := range e.Roles {\n\t\t\tif role.IsGlobal {\n\t\t\t\tr, err := b.store.GetGlobalRoleBySlug(role.Role)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"global role does not exist: %s\", role.Role)\n\t\t\t\t}\n\n\t\t\t\t_, err = b.store.CreateTemplateRole(db.TemplateRolePerm{\n\t\t\t\t\tTemplateID:  newTemplate.ID,\n\t\t\t\t\tRoleSlug:    r.Slug,\n\t\t\t\t\tProjectID:   b.meta.ID,\n\t\t\t\t\tPermissions: role.Permissions,\n\t\t\t\t})\n\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif k := findEntityByName[db.Role](&role.Role, b.roles); k == nil {\n\t\t\t\treturn fmt.Errorf(\"roles[].role does not exist in roles[].name\")\n\t\t\t} else {","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/restore.go#L350-L386","documentation":"When restoring template role permissions for a role marked IsGlobal, BackupTemplate.Restore calls store.GetGlobalRoleBySlug(role.Role). This error is thrown when that lookup fails, meaning the target instance has no global role with the given slug, so the template's global role permission cannot be recreated.","triggerScenarios":"Restoring a backup created on an instance that has a global role slug (roles[].role where isGlobal=true) which does not exist on the destination instance's database.","commonSituations":"Migrating projects between Semaphore instances with different RBAC setups; destination instance missing custom global roles; global role renamed or deleted on the target after the backup was taken.","solutions":["Create the missing global role with the exact slug on the destination instance before restoring","Change roles[].role in the backup to a slug that exists globally on the target","Remove the entry from templates[].roles if the global permission is not needed","Synchronize RBAC configuration between instances (e.g. via provisioning/setup) before import"],"exampleFix":"// before (backup.json)\n{\"roles\": [{\"role\": \"template-admin\", \"isGlobal\": true}]}\n// after: either create global role \"template-admin\" on the target, or map to an existing slug\n{\"roles\": [{\"role\": \"admin\", \"isGlobal\": true}]}","handlingStrategy":"validation","validationCode":"for i, t := range backup.Templates {\n    for _, r := range t.Roles {\n        if r.IsGlobal {\n            if _, err := store.GetGlobalRoleBySlug(r.Role); err != nil {\n                return fmt.Errorf(\"templates[%d]: global role %q missing on target\", i, r.Role)\n            }\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := backup.Restore(user, store, workflowStore); err != nil {\n    var target string\n    if _, scan := fmt.Sscanf(err.Error(), \"global role does not exist: %s\", &target); scan == nil {\n        // provision the global role on the target, then retry\n    }\n    return err\n}","preventionTips":["Provision identical global RBAC roles on source and destination instances before import","List target global role slugs and diff against the backup before restoring","Map renamed global roles in the backup prior to import"],"tags":["go","restore","rbac","roles"],"backgroundTag":"resource-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"}