Skip to content

Commit

Permalink
Fix conflict response code (cs3org#3031)
Browse files Browse the repository at this point in the history
* Return 409 Conflict instead of 400 when detecting recursive operations

* Add changelog
  • Loading branch information
aduffeck authored and kobergj committed Jul 7, 2022
1 parent b0a5e42 commit b060ddc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-response-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Return proper response code when detecting recursive copy/move operations

We changed the ocdav response code to "409 - Conflict" when a recursive operation was detected.

https://github.com/cs3org/reva/pull/3031
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Re
}
}
if isChild {
w.WriteHeader(http.StatusBadRequest)
w.WriteHeader(http.StatusConflict)
b, err := errors.Marshal(http.StatusBadRequest, "can not copy a folder into one of its children", "")
errors.HandleWebdavError(log, w, b, err)
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (s *svc) handleMove(ctx context.Context, w http.ResponseWriter, r *http.Req
}
}
if isChild {
w.WriteHeader(http.StatusBadRequest)
w.WriteHeader(http.StatusConflict)
b, err := errors.Marshal(http.StatusBadRequest, "can not move a folder into one of its children", "")
errors.HandleWebdavError(&log, w, b, err)
return
Expand Down
5 changes: 0 additions & 5 deletions tests/acceptance/expected-failures-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1490,10 +1490,5 @@ moving outside of the Shares folder gives 501 Not Implemented.
- [apiShareOperationsToShares1/gettingShares.feature:40](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L40)
- [apiShareOperationsToShares1/gettingShares.feature:39](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L39)

#### [apiWebdavMove1/moveFolder.feature:135 fails with 400 status](https://github.com/owncloud/ocis/issues/3023)
- [apiWebdavMove1/moveFolder.feature:147](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L147)
- [apiWebdavMove1/moveFolder.feature:148](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L148)
- [apiWebdavMove1/moveFolder.feature:153](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L153)

- Note: always have an empty line at the end of this file.
The bash script that processes this file may not process a scenario reference on the last line.
5 changes: 0 additions & 5 deletions tests/acceptance/expected-failures-on-S3NG-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1488,10 +1488,5 @@ _ocs: api compatibility, return correct status code_
- [apiShareOperationsToShares1/gettingShares.feature:40](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L40)
- [apiShareOperationsToShares1/gettingShares.feature:39](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L39)

#### [apiWebdavMove1/moveFolder.feature:135 fails with 400 status](https://github.com/owncloud/ocis/issues/3023)
- [apiWebdavMove1/moveFolder.feature:147](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L147)
- [apiWebdavMove1/moveFolder.feature:148](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L148)
- [apiWebdavMove1/moveFolder.feature:153](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L153)

Note: always have an empty line at the end of this file.
The bash script that processes this file may not process a scenario reference on the last line.

0 comments on commit b060ddc

Please sign in to comment.