{"record":{"id":"2d2fc1be3d8f4b4f","repo":"weaviate/weaviate","slug":"write-find-bucket-w","errorCode":null,"errorMessage":"write: find bucket: %w","messagePattern":"write: find bucket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/backup-gcs/client.go","lineNumber":381,"sourceCode":"\n\tobjectName := g.makeObjectName(overridePath, []string{backupID, key})\n\tif err := bucket.Object(objectName).Delete(ctx); err != nil {\n\t\treturn errors.Wrapf(err, \"failed to remove access-check gcs backup module %v\", objectName)\n\t}\n\n\treturn nil\n}\n\nfunc (g *gcsClient) Write(ctx context.Context, backupID, key, overrideBucket, overridePath string, r backup.ReadCloserWithError) (written int64, err error) {\n\t// Close the reader when done. Use CloseWithError to signal any error to the\n\t// producer so it sees the actual error instead of \"closed pipe\".\n\tdefer func() {\n\t\tr.CloseWithError(err)\n\t}()\n\n\tbucket, err := g.findBucket(ctx, overrideBucket)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"write: find bucket: %w\", err)\n\t}\n\n\t// create a new writer\n\tobjectPath := g.makeObjectName(overridePath, []string{backupID, key})\n\twriteCtx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\twriter := newChunkWriter(writeCtx, bucket.Object(objectPath), backupID)\n\n\t// copy\n\twritten, err = io.Copy(writer, r)\n\tif err != nil {\n\t\t// Cancelling abandons the upload. Closing the writer instead would finalize it,\n\t\t// storing the bytes copied so far as a complete object. Closing afterwards is\n\t\t// what ends the writer's trace span, and cannot revive the upload: the request\n\t\t// it would take needs the context that was just cancelled.\n\t\tcancel()\n\t\twriter.Close()\n\t\treturn written, fmt.Errorf(\"io.copy for gcs write %q: %w\", objectPath, err)","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/backup-gcs/client.go#L363-L399","documentation":"Write resolves the target bucket before uploading and wraps findBucket failures with 'write: find bucket: %w'. Since the writer is abandoned on error (CloseWithError), nothing is uploaded when the bucket cannot be resolved.","triggerScenarios":"An object Write during a backup when the bucket name is empty or the bucket.Attrs check fails (missing bucket, no permission, network error) for the override/configured bucket.","commonSituations":"Bucket deleted or renamed mid-backup; per-request bucket override misspelled; credentials rotated/revoked during a long backup; transient GCS outage at write time.","solutions":["Verify BACKUP_GCS_BUCKET (or the override) names an existing, accessible bucket","Re-authenticate / refresh service-account credentials","Retry the backup after confirming 'gsutil ls gs://<bucket>' works","Monitor for bucket policy changes if it worked previously"],"exampleFix":"// before\ngcsClient.Write(ctx, backupID, key, r) // with empty BACKUP_GCS_BUCKET\n// after\nif err := os.Setenv(\"BACKUP_GCS_BUCKET\", \"my-weaviate-backups\"); err != nil { ... }\ngcsClient.Write(ctx, backupID, key, r)","handlingStrategy":"retry","validationCode":"if os.Getenv(\"BACKUP_GCS_BUCKET\") == \"\" { return errors.New(\"BACKUP_GCS_BUCKET unset\") }\nif _, err := gcsClient.Bucket(os.Getenv(\"BACKUP_GCS_BUCKET\")).Attrs(ctx); err != nil {\n    return fmt.Errorf(\"bucket unusable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"n, err := g.Write(ctx, backupID, key, r)\nif err != nil {\n    if strings.Contains(err.Error(), \"write: find bucket\") {\n        // bucket-level issue; verify bucket exists/IAM, then retry backup\n    }\n    return err // partial upload already abandoned via CloseWithError\n}","preventionTips":["Verify bucket accessibility before starting long backups","Avoid renaming/deleting buckets during backup windows","Rotate credentials outside backup schedules"],"tags":["gcs","backup","write","cloud-storage"],"backgroundTag":"bucket-not-found","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}