s3tables: add error handling for json.Marshal calls
- Add error handling in handler_namespace.go (metadata marshaling) - Add error handling in handler_table.go (metadata and tags marshaling) - Add error handling in handler_policy.go (tag marshaling in TagResource and UntagResource) - Return proper errors with context instead of silently ignoring failures
This commit is contained in:
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user