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

[XrdHttp] A GET with 'Want-Digest' header request issued on a non-existing file will return a 404 error instead of 500 #2019

Conversation

ccaffy
Copy link
Contributor

@ccaffy ccaffy commented May 30, 2023

Fixes #2018.

@ccaffy ccaffy requested a review from abh3 May 30, 2023 14:58
src/XrdHttp/XrdHttpReq.cc Outdated Show resolved Hide resolved
@ccaffy ccaffy force-pushed the 2018-error-500-when-get-with-cksum-file-not-exist branch from 2a480e1 to 0d83adc Compare May 30, 2023 15:10
Copy link
Member

@abh3 abh3 left a comment

Choose a reason for hiding this comment

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

Like I said, I'm OK with this though I do have a question that may or may not lead to another change. So, if @amadio is OK with it so am I.

// In the case a user issues a GET with a 'Want-Digest' header on a non-existing file, the non-failing
// stat() will result in a failed checksum query giving a 500 error back to the user.
// Here we just return a 404 instead. httpStatusCode and httpStatusText contain the right reason why the request failed.
if(xrderrcode != kXR_NotFound) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm OK with the way it is but you could be a bit more discerning here. For instance, if the error is kXR_Unsupported then the status code should really be 501 with the text as returned by the server. Which leads to the question why override the server supplied error text with a generic one? Is the original error message lost somewhere? One would expect that the server's error message will better explain how to correct the problem.

Copy link
Member

Choose a reason for hiding this comment

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

Overriding is what used to be done, so I understand @ccaffy's choice. However, I agree that your suggestion is an improvement. I suppose we could have something like

switch(xrderrcode) {
case kXR_NotFound:
    break; // reuse error code and message already set
case kXR_Unsupported:
    httpStatusCode = 501;
    break;
default:
    httpStatusCode = 500;
    httpStatusText = "Underlying filesystem failed to calculate checksum.";
}
prot->SendSimpleResp(httpStatusCode, NULL, NULL, httpStatusText.c_str(), httpStatusText.length(), false);

Copy link
Contributor Author

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 improvement. Will apply it now ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

uhmmmmm wait please, IMO there may be another corner case, let's talk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After the chat with @ffurano , we are good to go! @amadio you may merge this fix whenever you want :)

Cheers,
Cedric

@xrootd-dev
Copy link

xrootd-dev commented May 31, 2023 via email

@ccaffy
Copy link
Contributor Author

ccaffy commented May 31, 2023

It was just that it was done like that. But I agree, let's then just use the server error text that is set by the XRootD layer, it will simplify the code!

@abh3
Copy link
Member

abh3 commented May 31, 2023 via email

@ccaffy ccaffy force-pushed the 2018-error-500-when-get-with-cksum-file-not-exist branch from aa038eb to 5286c00 Compare May 31, 2023 07:22
@amadio
Copy link
Member

amadio commented May 31, 2023

@ccaffy Very nice, but could you squash the two commits into a single one? Thanks!

…sting file will return a 404 error instead of 500
@ccaffy ccaffy force-pushed the 2018-error-500-when-get-with-cksum-file-not-exist branch from 5286c00 to 849d740 Compare May 31, 2023 07:26
@ccaffy
Copy link
Contributor Author

ccaffy commented May 31, 2023

@ccaffy Very nice, but could you squash the two commits into a single one? Thanks!

Done :)

@amadio amadio requested review from abh3 and amadio May 31, 2023 07:41
@ffurano ffurano merged commit 27d65c0 into xrootd:master May 31, 2023
14 checks passed
@amadio amadio added this to the 5.6.0 milestone Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[XrdHttp] Error 500 response when issuing GET with checksum request on a file that does not exist
5 participants