{"record":{"id":"e70a6ba6159f8441","repo":"kopia/kopia","slug":"can-t-retrieve-sources","errorCode":null,"errorMessage":"can't retrieve sources","messagePattern":"can't retrieve sources","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_snapshot_migrate.go","lineNumber":58,"sourceCode":"\tcmd.Flag(\"parallel\", \"Number of sources to migrate in parallel\").Default(\"1\").IntVar(&c.migrateParallel)\n\tcmd.Flag(\"apply-ignore-rules\", \"When migrating also apply current ignore rules\").BoolVar(&c.applyIgnoreRules)\n\tcmd.Action(svc.repositoryWriterActionWithMaintenance(c.run))\n\n\tc.svc = svc\n\tc.out.setup(svc)\n}\n\nfunc (c *commandSnapshotMigrate) run(ctx context.Context, destRepo repo.RepositoryWriter) error {\n\tsourceRepo, err := c.openSourceRepo(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"can't open source repository\")\n\t}\n\n\tdefer sourceRepo.Close(ctx) //nolint:errcheck\n\n\tsources, err := c.getSourcesToMigrate(ctx, sourceRepo)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"can't retrieve sources\")\n\t}\n\n\tsemaphore := make(chan struct{}, c.migrateParallel)\n\n\tvar (\n\t\twg              sync.WaitGroup\n\t\tmu              sync.Mutex\n\t\tcanceled        bool\n\t\tactiveUploaders = map[snapshot.SourceInfo]*upload.Uploader{}\n\t)\n\n\tc.svc.getProgress().StartShared()\n\n\tc.svc.onTerminate(func() {\n\t\tmu.Lock()\n\t\tdefer mu.Unlock()\n\n\t\tif canceled {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_snapshot_migrate.go#L40-L76","documentation":"kopia's `snapshot migrate` command wraps failures from getSourcesToMigrate, which lists the snapshots/sources available in the source repository, with the message \"can't retrieve sources\". It means the migration could not even enumerate what to copy — the failure happens before any snapshot data is transferred. The underlying cause (repository access, manifest listing, etc.) is in the wrapped error chain.","triggerScenarios":"Running `kopia snapshot migrate` where the call to c.getSourcesToMigrate(ctx, sourceRepo) returns a non-nil error, typically because snapshot.ListSnapshots fails against the just-opened source repository.","commonSituations":"Source repository connectivity drops right after opening (network repo), corrupted manifest data in the source repo, insufficient permissions to read manifests, or a source repo opened in read-only/broken state.","solutions":["Read the wrapped cause with `kopia logs` or --log-level=debug to see the root error and fix it (network, permissions, corruption).","Verify the source repository is healthy: run `kopia repository status` and `kopia snapshot list` against the source config manually.","Re-run after confirming network connectivity to the source repository backend (S3/Blob/SFTP etc.).","If manifests are corrupted, run `kopia blobs list --verify` / repair tools on the source repository before migrating."],"exampleFix":"// before\nsources, err := c.getSourcesToMigrate(ctx, sourceRepo)\nif err != nil {\n\treturn errors.Wrap(err, \"can't retrieve sources\")\n}\n// after: add retry for transient listing failures\nvar sources []snapshot.SourceInfo\nerr := retry.OnError(ctx, retry.Always, func() error {\n\tvar e error\n\tsources, e = c.getSourcesToMigrate(ctx, sourceRepo)\n\treturn e\n})\nif err != nil {\n\treturn errors.Wrap(err, \"can't retrieve sources\")\n}","handlingStrategy":"retry","validationCode":"// pre-check source repo is listable before migrating\nif err := exec.Command(\"kopia\", \"--config-file\", srcCfg, \"snapshot\", \"list\").Run(); err != nil {\n\treturn fmt.Errorf(\"source repo not listable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// Go: inspect wrapped cause before giving up\nif _, err := runMigrate(ctx); err != nil {\n\tif errors.Is(err, context.DeadlineExceeded) || isTransient(err) {\n\t\t// retry with backoff\n\t}\n\tlog.Fatalf(\"migrate failed: %v\", err)\n}","preventionTips":["Always verify the source repository opens and lists snapshots before scripting migrations.","Run migrations on a stable network connection; avoid spot-instance preemption windows.","Check kopia logs at debug level after any migration failure to capture the wrapped root cause."],"tags":["kopia","snapshot-migration","repository"],"backgroundTag":"api-request-failed","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}