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 0b7901ba5 fix(catalog/rest): report missing namespace on RenameView 
404 (#2454)
0b7901ba5 is described below

commit 0b7901ba54e12e515551e3a43d86f584255000a3
Author: jj.lee <[email protected]>
AuthorDate: Tue Nov 10 02:37:09 2026 +0900

    fix(catalog/rest): report missing namespace on RenameView 404 (#2454)
    
    * report missing ns on RenameView 404
    
    Signed-off-by: jx2lee <[email protected]>
    
    * add comments above req
    
    ---------
    
    Signed-off-by: jx2lee <[email protected]>
---
 catalog/rest/rest.go      |  6 +++++-
 catalog/rest/rest_test.go | 20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/catalog/rest/rest.go b/catalog/rest/rest.go
index d99368246..e2e129bc7 100644
--- a/catalog/rest/rest.go
+++ b/catalog/rest/rest.go
@@ -2746,11 +2746,15 @@ func (r *Catalog) RenameView(ctx context.Context, from, 
to table.Identifier) (*v
                return nil, err
        }
 
+       // The spec's rename 404 covers both a missing source view and a missing
+       // destination namespace; split it by error.type so a missing namespace 
is
+       // not reported as a missing view. LoadView and DropView need no 
override
+       // because the spec documents only NoSuchViewException for their 404s.
        _, err = doPost[payload, any](ctx, r.baseURI, path, payload{Source: 
src, Destination: dst}, r.cl,
                map[int]error{
                        http.StatusNotFound: catalog.ErrNoSuchView,
                        http.StatusConflict: catalog.ErrViewAlreadyExists,
-               }, allowNoContent())
+               }, allowNoContent(), 
withErrorTypeOverride(map[string]error{errTypeNoSuchNamespace: 
catalog.ErrNoSuchNamespace}))
        if err != nil {
                return nil, err
        }
diff --git a/catalog/rest/rest_test.go b/catalog/rest/rest_test.go
index 9eae1cbf5..29703f47d 100644
--- a/catalog/rest/rest_test.go
+++ b/catalog/rest/rest_test.go
@@ -3896,6 +3896,26 @@ func (r *RestCatalogSuite) TestRenameView404() {
        r.ErrorContains(err, "The given view does not exist")
 }
 
+func (r *RestCatalogSuite) TestRenameView404MissingNamespace() {
+       r.mux.HandleFunc("/v1/views/rename", func(w http.ResponseWriter, req 
*http.Request) {
+               w.Header().Set("Content-Type", "application/json")
+               w.WriteHeader(http.StatusNotFound)
+               json.NewEncoder(w).Encode(map[string]any{"error": errorResponse{
+                       Message: "Namespace does not exist: missing",
+                       Type:    "NoSuchNamespaceException",
+                       Code:    404,
+               }})
+       })
+
+       cat, err := rest.NewCatalog(context.Background(), "rest", r.srv.URL, 
rest.WithOAuthToken(TestToken))
+       r.Require().NoError(err)
+
+       _, err = cat.RenameView(context.Background(),
+               catalog.ToIdentifier("example", "source"), 
catalog.ToIdentifier("missing", "destination"))
+       r.ErrorIs(err, catalog.ErrNoSuchNamespace)
+       r.NotErrorIs(err, catalog.ErrNoSuchView)
+}
+
 func (r *RestCatalogSuite) TestRenameView409() {
        r.mux.HandleFunc("/v1/views/rename", func(w http.ResponseWriter, req 
*http.Request) {
                if !r.Equal(http.MethodPost, req.Method) {

Reply via email to