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

Updated 'dict' handling for responses without a body to use an empty dictionary #171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mraineri
Copy link
Contributor

Fix #170

@mraineri
Copy link
Contributor Author

@z46-dev you may want to try this out yourself; it seems to work well on some of the responses I've tried with no response bodies.

@z46-dev
Copy link

z46-dev commented Jan 14, 2025

So I did some more digging last night, apparently this gets loaded into the text field, not a blank string. I'm not sure if this is a violation of the redfish spec on Intel's part, but it seems that this internal server error is a generic response.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 - Internal Server Error</title>
 </head>
 <body>
  <h1>500 - Internal Server Error</h1>
 </body>
</html>```

@mraineri
Copy link
Contributor Author

Ah... crud... That's definitely breaking the spec...

@mraineri
Copy link
Contributor Author

mraineri commented Jan 17, 2025

@z46-dev so, some good news. We chatted about this a bit and we came to the rationale that there may be cases where a service simply cannot return a proper Redfish error response for all HTTP 500 cases, even though the spec requires it. Depending on the service's design, the overall web server may be croaking and simply have no context about the request even being a Redfish request (resulting in a stock error page from the web server).

So, I'll make the following change on top of what's already here. Specifically for 500 status codes, if the response does not unpack from JSON properly, return an empty dictionary rather than throwing an exception. However, for all other status codes, we still want to throw an exception since the service should be in a good enough state to know that it's servicing a Redfish request (and thus adhere to the Redfish error response requirements).

@z46-dev
Copy link

z46-dev commented Jan 17, 2025

@mraineri That's pretty good, thank you. I think that's a good resolution, since it doesn't need to change the spec, but does allow for handling of errors with the server you're requesting too. Thank you for your help!

@mraineri
Copy link
Contributor Author

@z46-dev I just pushed updates to this branch to support this corner case. Would you be able to test it on your end?

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.

500 Error Still Trying to Parse JSON Response
2 participants