This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new 183fde07 fix(io): handle new writer exists error (#726)
183fde07 is described below
commit 183fde0767ab2c00150938f4ee97a1d75d9f729b
Author: ferhat elmas <[email protected]>
AuthorDate: Mon Feb 16 21:00:02 2026 +0100
fix(io): handle new writer exists error (#726)
Signed-off-by: ferhat elmas <[email protected]>
---
io/blob.go | 2 +-
io/blob_test.go | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/io/blob.go b/io/blob.go
index 98970af2..14faf33e 100644
--- a/io/blob.go
+++ b/io/blob.go
@@ -165,7 +165,7 @@ func (bfs *blobFileIO) NewWriter(ctx context.Context, path
string, overwrite boo
}
if !overwrite {
- if exists, err := bfs.Exists(ctx, path); exists {
+ if exists, err := bfs.Exists(ctx, path); err != nil || exists {
if err != nil {
return nil, &fs.PathError{Op: "new writer",
Path: path, Err: err}
}
diff --git a/io/blob_test.go b/io/blob_test.go
index fe614b67..c6029809 100644
--- a/io/blob_test.go
+++ b/io/blob_test.go
@@ -20,6 +20,7 @@ package io
import (
"context"
"io"
+ "io/fs"
"testing"
"github.com/stretchr/testify/assert"
@@ -81,6 +82,25 @@ func TestDefaultKeyExtractor(t *testing.T) {
}
}
+func TestNewWriterExistsError(t *testing.T) {
+ ctx := context.Background()
+
+ bucket := memblob.OpenBucket(nil)
+
+ bfs := &blobFileIO{
+ Bucket: bucket,
+ keyExtractor: func(path string) (string, error) { return path,
nil },
+ ctx: ctx,
+ }
+ require.NoError(t, bucket.Close())
+
+ _, err := bfs.NewWriter(ctx, "test-file", false, nil)
+
+ var pathErr *fs.PathError
+ require.ErrorAs(t, err, &pathErr, "error should be a PathError wrapping
the Exists failure")
+ require.Equal(t, "new writer", pathErr.Op)
+}
+
type trackingReadCloser struct {
io.ReadCloser
closed *bool