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 a250163b fix: return err when not nil in WriteTableMetadata (#574)
a250163b is described below

commit a250163b7c8ad15df84cb3b2ffdc266b789b6c4d
Author: Alessandro Nori <alessandro.n...@datadoghq.com>
AuthorDate: Tue Sep 23 18:02:35 2025 +0200

    fix: return err when not nil in WriteTableMetadata (#574)
    
    - Return the error when `fs` fails to create a file at the provided
    location
    - Refactor the code to reuse `WriteTableMetadata` code in
    `WriteMetadata`
---
 catalog/internal/utils.go | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/catalog/internal/utils.go b/catalog/internal/utils.go
index 97ecdffd..493f32e9 100644
--- a/catalog/internal/utils.go
+++ b/catalog/internal/utils.go
@@ -45,7 +45,7 @@ func GetMetadataLoc(location string, newVersion uint) string {
 func WriteTableMetadata(metadata table.Metadata, fs io.WriteFileIO, loc 
string) error {
        out, err := fs.Create(loc)
        if err != nil {
-               return nil
+               return err
        }
 
        return errors.Join(
@@ -65,15 +65,7 @@ func WriteMetadata(ctx context.Context, metadata 
table.Metadata, loc string, pro
                return errors.New("filesystem IO does not support writing")
        }
 
-       out, err := wfs.Create(loc)
-       if err != nil {
-               return nil
-       }
-
-       return errors.Join(
-               json.NewEncoder(out).Encode(metadata),
-               out.Close(),
-       )
+       return WriteTableMetadata(metadata, wfs, loc)
 }
 
 func UpdateTableMetadata(base table.Metadata, updates []table.Update, 
metadataLoc string) (table.Metadata, error) {

Reply via email to