kopia/kopia · error
error parsing storage config for bucket
Error message
error parsing storage config for bucket %q
What it means
Wrapped error from StorageConfig.Load during newStorageWithCredentials: after fetching the storage-config blob (ConfigName) from the bucket, its JSON contents could not be decoded. The parse error is in errors.Cause.
Solutions
- Inspect and fix the JSON in the config blob at key ConfigName in the bucket
- Delete/recreate the repository config blob if corrupted (will require re-connect)
- Ensure all clients use a compatible kopia version
- Check for proxy/upload truncation that cut off the JSON
Defensive patterns
Strategy: try-catch
Validate before calling
var probe map[string]any
if err := json.Unmarshal(configBlobBytes, &probe); err != nil {
return fmt.Errorf("repository config blob is not valid JSON: %w", err)
} Type guard
func isLikelyJSON(b []byte) bool {
t := bytes.TrimSpace(b)
return len(t) > 0 && (t[0] == '{' || t[0] == '[')
} Try / catch
store, err := s3.New(ctx, &opt)
if err != nil && strings.Contains(err.Error(), "error parsing storage config") {
// inspect/repair the config blob or re-initialize the repository
return fmt.Errorf("corrupt repository config: %w", err)
} Prevention
- Never hand-edit blobs in the repository bucket
- Watch for proxies/CDNs that substitute error pages for objects
- Keep all clients on the same kopia version
- Verify uploads are complete after network interruptions
When it happens
Trigger: The kopia.repository/config blob in the S3 bucket exists but contains invalid or truncated JSON — e.g. written by a different/older format, corrupted upload, or manually edited.
Common situations: Bucket previously used by another tool; partial upload of the config blob; hand-editing of stored config; version mismatch between client formats.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- error parsing JSON
- error parsing JSON
- error retrieving storage config from bucket
- error unmarshaling connection info JSON
- errors indenting JSON
AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07).
Data as JSON: /api/errors/2b60dca73ad780f2.
Report an issue: GitHub.
Appendix: source
Thrown at repo/blob/s3/s3_storage.go:465
return nil, err
}
cli, err := minio.New(opt.Endpoint, minioOpts)
if err != nil {
return nil, errors.Wrap(err, "unable to create client")
}
s := s3Storage{
Options: *opt,
cli: cli,
storageConfig: &StorageConfig{},
}
var scOutput gather.WriteBuffer
if getBlobErr := s.GetBlob(ctx, ConfigName, 0, -1, &scOutput); getBlobErr == nil {
if scErr := s.storageConfig.Load(scOutput.Bytes().Reader()); scErr != nil {
return nil, errors.Wrapf(scErr, "error parsing storage config for bucket %q", opt.BucketName)
}
} else if !errors.Is(getBlobErr, blob.ErrBlobNotFound) {
return nil, errors.Wrapf(getBlobErr, "error retrieving storage config from bucket %q", opt.BucketName)
}
return &s, nil
}
func init() {
blob.AddSupportedStorage(s3storageType, Options{}, New)
}
View on GitHub (pinned to 82495e54b5)