{"record":{"id":"e5ea1039c2ff24dd","repo":"semaphoreui/semaphore","slug":"failed-to-import-s-s","errorCode":null,"errorMessage":"failed to import %s: %s","messagePattern":"failed to import (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/export/Exporter.go","lineNumber":529,"sourceCode":"\tfor _, name := range keys {\n\n\t\tprogress := &ProgressBar{printer: func(progress float32, count int64) {\n\t\t\tstrLen := len(name)\n\t\t\tif progress == 1 {\n\t\t\t\tspaces := fmt.Sprintf(\"%*s\", 50-strLen-len(strconv.FormatInt(count, 10)), \" \")\n\t\t\t\tfmt.Printf(\"\\rImported %s%s %d\", name, spaces, count)\n\t\t\t} else {\n\t\t\t\tspaces := fmt.Sprintf(\"%*s\", 45-strLen, \" \")\n\t\t\t\tfmt.Printf(\"\\rImporting %s%s %d%%\", name, spaces, int(progress*100))\n\t\t\t}\n\t\t}, progress: 0}\n\n\t\tprogress.updateForce(0, 0)\n\t\texporter := p.exporters[name]\n\t\terr := exporter.restore(store, p, progress)\n\t\tif err != nil {\n\t\t\tfmt.Println()\n\t\t\treturn fmt.Errorf(\"failed to import %s: %s\", name, err.Error())\n\t\t}\n\t\tprogress.updateForce(1, progress.count)\n\t\tfmt.Println()\n\n\t\terrCount := len(exporter.getErrors())\n\t\tif errCount > 0 {\n\t\t\tfmt.Printf(\"    Errors: %d\\n\", errCount)\n\n\t\t\tif errLogSize > 0 {\n\t\t\t\tfor i, err := range exporter.getErrors() {\n\t\t\t\t\tif i > errLogSize {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tfmt.Println(\"      \", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\texporter.clear()","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/export/Exporter.go#L511-L547","documentation":"The import runner wraps each exporter's restore() failure with the failing type name, producing 'failed to import <type>: <cause>'. Like the export counterpart, the actionable information is the inner cause (missing key mappings, constraint violations, etc.).","triggerScenarios":"During Import/Restore(), exporter.restore(store, p, progress) returns an error for type `name`; the chain stops and returns the wrapped message (afterwards also counting exporter.getErrors()).","commonSituations":"Importing into a database with conflicting/missing referenced entities ('key not found'); schema differences between source and target Semaphore versions; unique-constraint collisions on insert.","solutions":["Inspect the inner error after 'failed to import <type>:' and address that root cause","Check exporter.getErrors() for per-entity problems reported during the same run","Ensure the target database is compatible (version/schema) with the export file, then retry the import"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: verify referential completeness of the export file\nfor _, ref := range exportRefs {\n    if !targetStore.Exists(ref.Type, ref.Key) {\n        return fmt.Errorf(\"import would fail: missing %s %s\", ref.Type, ref.Key)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := chain.Restore(store)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"failed to import \") {\n        cause := strings.SplitN(err.Error(), \": \", 2)[1]\n        log.Errorf(\"import failed, root cause: %s\", cause)\n    }\n    return err\n}","preventionTips":["Import into a schema/version compatible with the export source","Inspect exporter.getErrors() for per-entity import failures","Back up the target database before importing"],"tags":["go","import","error-wrapping"],"backgroundTag":"import-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"}