Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle return code of streamCopy in WebDAV put #20927

Merged
merged 1 commit into from
Jan 15, 2016

Conversation

MorrisJobke
Copy link
Contributor

  • throw a different exception if streamCopy failed

cc @DeepDiver1975 @PVince81 @dragotin

Is this what @dragotin want to have? (See #9832 (comment) )

@MorrisJobke MorrisJobke added this to the 9.0-current milestone Dec 3, 2015
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @icewind1991, @PVince81 and @DeepDiver1975 to be potential reviewers

@icewind1991
Copy link
Contributor

Looks good 👍

@dragotin
Copy link
Contributor

dragotin commented Dec 3, 2015

👍
Yes, of course this does not solve a problem, but makes debugging easier. The real question is: Why does the streamCopy fail, if it does?

if (isset($_SERVER['CONTENT_LENGTH'])) {
$expected = $_SERVER['CONTENT_LENGTH'];
}
throw new BadRequest('error while copying file to target location (copied bytes: ' . $count . ', expected filesize: '. $expected .' )');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really a bad request?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, sounds rather like an internal server error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Therefore I added the discussion label. What is the wanted exception for the Sabre stack? cc @DeepDiver1975 @PVince81 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the HTTP codes but didn't find anything adequate.

The only one maybe, if it was about external storages, would be "408 Request Timeout".

There is also "422 Unprocessable Entity" when the data uploaded did not match expectations, but that's more of a validation issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I read "Bad request" usually tells the client to NOT repeat the request.
So it's more like "500 Internal Server error" then... Just throw a regular \Sabre\Exception, it will be 500.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@PVince81
Copy link
Contributor

PVince81 commented Dec 4, 2015

There is one valid case where streamCopy would not return all bytes, that's when the quota is reached. But the it will also return false.

Other failures could be when writing to external storage but the connection took too long to respond, or the network connection to the ext storage is flaky.

@MorrisJobke MorrisJobke force-pushed the handle-return-code-on-webdav-put branch from 58eae5e to 3dc3448 Compare December 4, 2015 13:05
if (isset($_SERVER['CONTENT_LENGTH'])) {
$expected = $_SERVER['CONTENT_LENGTH'];
}
throw new Exception('Error while copying file to target location (copied bytes: ' . $count . ', expected filesize: '. $expected .' )');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a non-cryptic exception text. Most non-tech savy people having a look at their logfiles probably have no idea what this means and knows what to do when getting this exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PVince81 @icewind1991 @dragotin Do you have a better exception text in mind? I would change that to something more meaningful happily

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this. At least it makes it possible to distinguish the error from the other one.

* throw a different exception if streamCopy failed
@PVince81 PVince81 force-pushed the handle-return-code-on-webdav-put branch from 3dc3448 to 43f5d8a Compare January 11, 2016 11:13
@PVince81
Copy link
Contributor

Rebased to wake up CI

@DeepDiver1975
Copy link
Member

👍

DeepDiver1975 added a commit that referenced this pull request Jan 15, 2016
Handle return code of streamCopy in WebDAV put
@DeepDiver1975 DeepDiver1975 merged commit 6a7be4d into master Jan 15, 2016
@DeepDiver1975 DeepDiver1975 deleted the handle-return-code-on-webdav-put branch January 15, 2016 12:33
@PVince81
Copy link
Contributor

@karlitschek @MorrisJobke backport to 8.2, 8.1, 8.0 ?

@MorrisJobke
Copy link
Contributor Author

@karlitschek @MorrisJobke backport to 8.2, 8.1, 8.0 ?

Fine from my side

@karlitschek
Copy link
Contributor

yes. makes a ton of sense. please backport 👍

@MorrisJobke
Copy link
Contributor Author

I backported to stable8.2 and stable8.1: #21747 and #21748 - stable8.0 is a completely different code path and I don't think that it's worth to put in more effort here for an adjusted error message.

@dragotin
Copy link
Contributor

@MorrisJobke agreed.

@ghost
Copy link

ghost commented Jan 17, 2016

Just some minor but important questions:

What is StreamCopy, when does that issue happen and how is that issue mitigated?

Those questions are definitely coming up as the error message is just cryptic and not understanable by users.

@PVince81
Copy link
Contributor

streamCopy here is used at the moment where the data is read from the PHP Input and copied into a part file on the target storage. If the target storage is not local (ex: FTP) and that storage is slow / not available / broken, it is likely that streamCopy will fail either at the beginning, or in the middle of the copy.

In this case, the issue is most likely due to the target storage and not the client<->server connection.

@ghost
Copy link

ghost commented Jan 18, 2016

@PVince81 Thanks for the info. So why not adding this to the message as a possible reason so it would at least include some info for users?

@ghost
Copy link

ghost commented Feb 9, 2016

Have raised owncloud-archive/documentation#2145

Please at least help to document the reason for this error (and also the old one in #9832). This would really help supporters trying to help other people.

@voroyam voroyam mentioned this pull request Nov 19, 2018
4 tasks
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants