{"record":{"id":"1c9b1d2820e6b820","repo":"kopia/kopia","slug":"error-listing-blobs-1c9b1d","errorCode":null,"errorMessage":"error listing blobs","messagePattern":"error listing blobs","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_repository_create.go","lineNumber":113,"sourceCode":"\n\t\tRetentionMode:                     blob.RetentionMode(c.retentionMode),\n\t\tRetentionPeriod:                   c.retentionPeriod,\n\t\tFormatBlockKeyDerivationAlgorithm: c.createBlockKeyDerivationAlgorithm,\n\t}\n}\n\nfunc (c *commandRepositoryCreate) ensureEmpty(ctx context.Context, s blob.Storage) error {\n\thasDataError := errors.New(\"has data\")\n\n\terr := s.ListBlobs(ctx, \"\", func(_ blob.Metadata) error {\n\t\treturn hasDataError\n\t})\n\n\tif errors.Is(err, hasDataError) {\n\t\treturn errors.New(\"found existing data in storage location\")\n\t}\n\n\treturn errors.Wrap(err, \"error listing blobs\")\n}\n\nfunc (c *commandRepositoryCreate) runCreateCommandWithStorage(ctx context.Context, st blob.Storage) error {\n\terr := c.ensureEmpty(ctx, st)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unable to get repository storage\")\n\t}\n\n\toptions := c.newRepositoryOptionsFromFlags()\n\n\tpass, err := c.svc.getPasswordFromFlags(ctx, true, false)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"getting password\")\n\t}\n\n\tlog(ctx).Info(\"Initializing repository with:\")\n\n\tif options.BlockFormat.Version != 0 {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_repository_create.go#L95-L131","documentation":"`ensureEmpty` lists blobs in the target storage before creating a repository, aborting early if any blob exists. When `ListBlobs` itself fails (other than the internal sentinel meaning 'data found'), the error is wrapped as 'error listing blobs'. It signals that Kopia could not verify the bucket/container is empty, typically due to a storage backend connectivity, credentials, or permissions problem — not that data exists.","triggerScenarios":"Calling `kopia repository create <provider> ...` where the underlying `blob.Storage.ListBlobs(ctx, \"\", ...)` call returns a non-nil error (excluding the hasData sentinel). Causes include invalid bucket/container name, missing or expired credentials, no network access to the storage endpoint, or insufficient list permissions (e.g. s3:ListBucket denied).","commonSituations":"Wrong AWS/GCS/Azure credentials or profiles; nonexistent or misspelled bucket names; IAM policies without ListObjects permission; corporate proxies or offline environments; endpoint misconfiguration for S3-compatible providers (MinIO, B2, rclone).","solutions":["Verify the storage location (bucket/container) exists and the name is spelled correctly in the provider flags.","Test credentials and network access with the provider's CLI (e.g. `aws s3 ls s3://bucket`) using the same account/profile.","Check IAM/storage permissions include list operations on the bucket/container.","If the location is intentionally non-empty and stale, empty it or choose another location — but first fix the list error itself, since 'found existing data' is reported separately."],"exampleFix":"// before (failing flags)\nkopia repository create s3 --bucket=my-bukket --access-key=AKIA... --secret=...\n// after (corrected bucket + verified credentials)\nkopia repository create s3 --bucket=my-bucket --region=us-east-1 --access-key=AKIA... --secret=...","handlingStrategy":"validation","validationCode":"// Before creating, verify the storage location is reachable and listable.\nst, err := f.Connect(ctx, true, formatVersion)\nif err != nil { return err }\nerr := st.ListBlobs(ctx, \"\", func(md blob.Metadata) error { return nil })\nif err != nil {\n\treturn fmt.Errorf(\"storage not usable (check bucket name, credentials, network): %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := c.ensureEmpty(ctx, st); err != nil {\n\tif strings.Contains(err.Error(), \"error listing blobs\") {\n\t\t// backend access problem: inspect unwrapped cause\n\t\tlog.Fatalf(\"storage backend unreachable: %v\", errors.Unwrap(err))\n\t}\n\treturn err\n}","preventionTips":["Validate bucket/container names and credentials with the provider CLI before running kopia create.","Grant list permissions (e.g. s3:ListBucket) to the principal used by kopia.","Test network/proxy reachability to the storage endpoint from the same host.","Use `kopia repository validate-provider` to confirm backend compatibility."],"tags":["storage","blob-listing","kopia","cli"],"backgroundTag":"resource-not-found","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"}