{"record":{"id":"fd9f6e0cb0941e93","repo":"semaphoreui/semaphore","slug":"error-at-views-d-s","errorCode":null,"errorMessage":"error at views[%d]: %s","messagePattern":"error at views\\[(.+?)\\]: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/project/restore.go","lineNumber":543,"sourceCode":"\n\tnewWorkflow, err := b.workflowStore.CreateWorkflowTemplate(workflow)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tb.workflows = append(b.workflows, newWorkflow)\n\treturn nil\n}\n\nfunc (backup *BackupFormat) Verify() error {\n\tfor i, o := range backup.Environments {\n\t\tif err := o.Verify(backup); err != nil {\n\t\t\treturn fmt.Errorf(\"error at environments[%d]: %s\", i, err.Error())\n\t\t}\n\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 {","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/project/restore.go#L525-L561","documentation":"BackupFormat.Verify() validates each entry in backup.Views by calling BackupView.Verify and wraps any failure with the view's index. This error tells the caller that the view at views[i] failed validation (e.g. duplicate names or broken references inside the view).","triggerScenarios":"Calling BackupFormat.Verify() when the view at index i fails verification — typically a duplicate views[].name (via verifyDuplicate) or a reference inside the view to a non-existent entity.","commonSituations":"Backup files with duplicated view names after merging; views copied between projects keeping stale references; generated backups that did not deduplicate view names.","solutions":["Read the wrapped inner message to identify the failing view's specific problem","Rename or remove the duplicate views[i].name so view names are unique in the backup","Fix any entity reference inside the view to point at an existing backup entry","Re-export the backup after fixing so Verify() passes cleanly"],"exampleFix":"// before\n{\"views\": [{\"name\": \"dashboard\"}, {\"name\": \"dashboard\"}]}\n// after\n{\"views\": [{\"name\": \"dashboard\"}, {\"name\": \"dashboard-2\"}]}","handlingStrategy":"try-catch","validationCode":"if err := backup.Verify(); err != nil {\n    var idx int\n    if n, _ := fmt.Sscanf(err.Error(), \"error at views[%d]\", &idx); n == 1 {\n        log.Printf(\"view entry %d is invalid\", idx)\n    }\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := backup.Verify(); err != nil {\n    if strings.HasPrefix(err.Error(), \"error at views[\") {\n        // parse index and inner message; deduplicate or fix backup.Views[i]\n        return fmt.Errorf(\"invalid backup: %w\", err)\n    }\n    return err\n}","preventionTips":["Ensure view names are unique within the backup before Verify","Run Verify() after any manual edit to views[]","Re-export backups instead of merging view sections by hand","Check the wrapped inner message for the real cause"],"tags":["go","backup","validation","views"],"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"}