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

MSPileup service should acknowledge and return proper data-type within HTTP request #11923

Open
vkuznet opened this issue Mar 6, 2024 · 1 comment

Comments

@vkuznet
Copy link
Contributor

vkuznet commented Mar 6, 2024

Impact of the bug
If data-service does not return proper data-type from HTTP request it can cause parser of this request fail.

Describe the bug
I do not know if it is feature of MSPileup or in general WMCore web framework but during integration tests with MSPileup I found the following:

  • if user place HTTP request and provide HTTP header with specific Accept mime type, e.g. applciation/json, the returned results can be presented in different mime type when error occur.

How to reproduce it

# request application/json response from the server
scurl -X PUT -H "Accept: application/json" -H "Content-type: application/json" -d@./pileup-fraction.json https://cmsweb-test10.cern.ch/ms-pileup/data/pileup

# in my case server returns and 400 error in HTML format
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
    <title>400 Bad Request</title>
    <style type="text/css">
    #powered_by {
        margin-top: 20px;
        border-top: 2px solid black;
        font-style: italic;
    }

    #traceback {
        color: red;
    }
    </style>
</head>
    <body>
        <h2>400 Bad Request</h2>
        <p>MSPileupError: container fraction in provided spec {'pileupName': '/MinBias_TuneCP5_14TeV-pythia8/PhaseIITDRSpring19GS-106X_upgrade2023_realistic_v2_ext1-v1/GEN-SIM'} is identical to one in MongoDB, code: 8</p>
        <pre id="traceback"></pre>
    <div id="powered_by">
      <span>
        Powered by <a href="http://www.cherrypy.dev">CherryPy 18.8.0</a>
      </span>
    </div>
    </body>
</html>

Obviously it is a bug in HTTP server since client requested data in application/json and server should properly acknowledge it, if it can it should return back results in that format, if this format is not supported it should return proper message that such format is not supported. In case above it returned 400 status code that request fails and represented it in HTML format.

Expected behavior
In this case the HTTP response should be in JSON format, e.g.

[{"http_code": 400, "message": "MSPileupError: container fraction in provided spec {'pileupName': '/MinBias_TuneCP5_14TeV-pythia8/PhaseIITDRSpring19GS-106X_upgrade2023_realistic_v2_ext1-v1/GEN-SIM'} is identical to one in MongoDB", "code": 8}]

or similar

Additional context and error message
As I stated it may be generic issue with WMCore web framework and it may be not specific to MSPileup service.

@vkuznet vkuznet changed the title MSPIleup service should acknowledge and return proper data-type within HTTP request MSPileup service should acknowledge and return proper data-type within HTTP request Mar 6, 2024
@amaltaro
Copy link
Contributor

amaltaro commented Mar 6, 2024

This is a general behavior of the WMCore HTTP server. Whenever it fails with a status code (>=400 - client or server error), an exception is raised within the HTTP server and it's formatted as you see, HTML. The response headers should give extra insight on the actual error.

If my memory does not fail me, I think we had this discussion and you (initially) implemented a json response with the relevant information. Or maybe that has been implemented in MSOutput, I don't really recall now...

Said that, I would be in favor of leaving this for the future, as it is not really required for the partial pileup feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants