From 11d7409a7436d295feac1a369c37d0f76e214de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 26 Jan 2024 08:41:41 +0100 Subject: [PATCH 1/3] Bail out on empty PUT requests --- pkg/rhttp/datatx/manager/simple/simple.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/rhttp/datatx/manager/simple/simple.go b/pkg/rhttp/datatx/manager/simple/simple.go index a89ce71ecd..6699c9f77a 100644 --- a/pkg/rhttp/datatx/manager/simple/simple.go +++ b/pkg/rhttp/datatx/manager/simple/simple.go @@ -93,6 +93,13 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) { defer func() { metrics.UploadsActive.Sub(1) }() + + if r.ContentLength == 0 { + sublog.Info().Msg("received invalid 0-byte PUT request") + w.WriteHeader(http.StatusBadRequest) + return + } + fn := r.URL.Path defer r.Body.Close() From 00f9b2b22789b0db9e4abe090d49e664c4d5b1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 26 Jan 2024 08:42:39 +0100 Subject: [PATCH 2/3] Fix detection of already finished requests --- internal/http/services/appprovider/appprovider.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index c121657885..2181e98b95 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -276,9 +276,8 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { return } defer httpRes.Body.Close() - if httpRes.StatusCode == http.StatusForbidden { + if httpRes.StatusCode == http.StatusBadRequest { // the file upload was already finished since it is a zero byte file - // TODO: why do we get a 401 then!? } else if httpRes.StatusCode != http.StatusOK { writeError(w, r, appErrorServerError, "failed to create the file", nil) return From f2c52dde9686dcaf0eff8a271496fabb0247a097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 26 Jan 2024 08:47:18 +0100 Subject: [PATCH 3/3] Add changelog --- changelog/unreleased/fix-creating-documents.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/unreleased/fix-creating-documents.md diff --git a/changelog/unreleased/fix-creating-documents.md b/changelog/unreleased/fix-creating-documents.md new file mode 100644 index 0000000000..4206541b40 --- /dev/null +++ b/changelog/unreleased/fix-creating-documents.md @@ -0,0 +1,5 @@ +Bugfix: Fix creating documents in the approvider + +We fixed a problem with the approvider where an error was reported to the user even though the file was created properly. + +https://github.com/cs3org/reva/pull/4479