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 b2f76956 fix(table): handle error in unmarshal of snapshot ref (#646)
b2f76956 is described below

commit b2f76956f49252ffb18f2907104390a360387a36
Author: ferhat elmas <[email protected]>
AuthorDate: Tue Dec 9 16:36:09 2025 +0100

    fix(table): handle error in unmarshal of snapshot ref (#646)
    
    Signed-off-by: ferhat elmas <[email protected]>
---
 table/refs.go      |  2 +-
 table/refs_test.go | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/table/refs.go b/table/refs.go
index 7e847371..8812723e 100644
--- a/table/refs.go
+++ b/table/refs.go
@@ -53,7 +53,7 @@ func (s *SnapshotRef) UnmarshalJSON(b []byte) error {
        aux := (*Alias)(s)
 
        if err := json.Unmarshal(b, aux); err != nil {
-               return nil
+               return err
        }
 
        switch s.SnapshotRefType {
diff --git a/table/refs_test.go b/table/refs_test.go
index d8b54e4d..afbde119 100644
--- a/table/refs_test.go
+++ b/table/refs_test.go
@@ -25,6 +25,17 @@ import (
        "github.com/stretchr/testify/assert"
 )
 
+func TestInvalidSnapshotRef(t *testing.T) {
+       ref := `{
+               "snapshot-id": "3051729675574597004",
+               "type": "foobar"
+       }`
+
+       var snapRef table.SnapshotRef
+       err := json.Unmarshal([]byte(ref), &snapRef)
+       assert.Error(t, err)
+}
+
 func TestInvalidSnapshotRefType(t *testing.T) {
        ref := `{
                "snapshot-id": 3051729675574597004,

Reply via email to