diff --git a/weed/s3api/s3tables/handler_namespace.go b/weed/s3api/s3tables/handler_namespace.go index 027ce8a8b..777de2c05 100644 --- a/weed/s3api/s3tables/handler_namespace.go +++ b/weed/s3api/s3tables/handler_namespace.go @@ -81,7 +81,11 @@ func (h *S3TablesHandler) handleCreateNamespace(w http.ResponseWriter, r *http.R OwnerID: h.accountID, } - metadataBytes, _ := json.Marshal(metadata) + metadataBytes, err := json.Marshal(metadata) + if err != nil { + h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, "failed to marshal namespace metadata") + return fmt.Errorf("failed to marshal metadata: %w", err) + } err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { // Create namespace directory diff --git a/weed/s3api/s3tables/handler_policy.go b/weed/s3api/s3tables/handler_policy.go index bcb0c902a..e0e62ad39 100644 --- a/weed/s3api/s3tables/handler_policy.go +++ b/weed/s3api/s3tables/handler_policy.go @@ -297,7 +297,11 @@ func (h *S3TablesHandler) handleTagResource(w http.ResponseWriter, r *http.Reque } // Write merged tags - tagsBytes, _ := json.Marshal(existingTags) + tagsBytes, err := json.Marshal(existingTags) + if err != nil { + h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, "failed to marshal tags") + return fmt.Errorf("failed to marshal tags: %w", err) + } err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { return h.setExtendedAttribute(client, resourcePath, extendedKey, tagsBytes) }) @@ -387,7 +391,11 @@ func (h *S3TablesHandler) handleUntagResource(w http.ResponseWriter, r *http.Req } // Write updated tags - tagsBytes, _ := json.Marshal(tags) + tagsBytes, err := json.Marshal(tags) + if err != nil { + h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, "failed to marshal tags") + return fmt.Errorf("failed to marshal tags: %w", err) + } err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { return h.setExtendedAttribute(client, resourcePath, extendedKey, tagsBytes) }) diff --git a/weed/s3api/s3tables/handler_table.go b/weed/s3api/s3tables/handler_table.go index 3a96f3650..6054a85d4 100644 --- a/weed/s3api/s3tables/handler_table.go +++ b/weed/s3api/s3tables/handler_table.go @@ -101,7 +101,11 @@ func (h *S3TablesHandler) handleCreateTable(w http.ResponseWriter, r *http.Reque Schema: req.Metadata, } - metadataBytes, _ := json.Marshal(metadata) + metadataBytes, err := json.Marshal(metadata) + if err != nil { + h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, "failed to marshal table metadata") + return fmt.Errorf("failed to marshal metadata: %w", err) + } err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { // Create table directory @@ -122,7 +126,10 @@ func (h *S3TablesHandler) handleCreateTable(w http.ResponseWriter, r *http.Reque // Set tags if provided if len(req.Tags) > 0 { - tagsBytes, _ := json.Marshal(req.Tags) + tagsBytes, err := json.Marshal(req.Tags) + if err != nil { + return fmt.Errorf("failed to marshal tags: %w", err) + } if err := h.setExtendedAttribute(client, tablePath, ExtendedKeyTags, tagsBytes); err != nil { return err }