{"record":{"id":"2b60dca73ad780f2","repo":"kopia/kopia","slug":"error-parsing-storage-config-for-bucket-q","errorCode":null,"errorMessage":"error parsing storage config for bucket %q","messagePattern":"error parsing storage config for bucket %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/blob/s3/s3_storage.go","lineNumber":465,"sourceCode":"\t\treturn nil, err\n\t}\n\n\tcli, err := minio.New(opt.Endpoint, minioOpts)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"unable to create client\")\n\t}\n\n\ts := s3Storage{\n\t\tOptions:       *opt,\n\t\tcli:           cli,\n\t\tstorageConfig: &StorageConfig{},\n\t}\n\n\tvar scOutput gather.WriteBuffer\n\n\tif getBlobErr := s.GetBlob(ctx, ConfigName, 0, -1, &scOutput); getBlobErr == nil {\n\t\tif scErr := s.storageConfig.Load(scOutput.Bytes().Reader()); scErr != nil {\n\t\t\treturn nil, errors.Wrapf(scErr, \"error parsing storage config for bucket %q\", opt.BucketName)\n\t\t}\n\t} else if !errors.Is(getBlobErr, blob.ErrBlobNotFound) {\n\t\treturn nil, errors.Wrapf(getBlobErr, \"error retrieving storage config from bucket %q\", opt.BucketName)\n\t}\n\n\treturn &s, nil\n}\n\nfunc init() {\n\tblob.AddSupportedStorage(s3storageType, Options{}, New)\n}\n","sourceCodeStart":447,"sourceCodeEnd":477,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/repo/blob/s3/s3_storage.go#L447-L477","documentation":"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.","triggerScenarios":"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.","commonSituations":"Bucket previously used by another tool; partial upload of the config blob; hand-editing of stored config; version mismatch between client formats.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var probe map[string]any\nif err := json.Unmarshal(configBlobBytes, &probe); err != nil {\n    return fmt.Errorf(\"repository config blob is not valid JSON: %w\", err)\n}","typeGuard":"func isLikelyJSON(b []byte) bool {\n    t := bytes.TrimSpace(b)\n    return len(t) > 0 && (t[0] == '{' || t[0] == '[')\n}","tryCatchPattern":"store, err := s3.New(ctx, &opt)\nif err != nil && strings.Contains(err.Error(), \"error parsing storage config\") {\n    // inspect/repair the config blob or re-initialize the repository\n    return fmt.Errorf(\"corrupt repository config: %w\", err)\n}","preventionTips":["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"],"tags":["json","s3","config","parsing"],"backgroundTag":"json-parse-error","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"}