DMTF / Redfish-Service-Validator

The Redfish Service Validator is a Python3 tool for checking conformance of any "device" with a Redfish service interface against Redfish CSDL schema
Other
42 stars 34 forks source link

Traceback reported when registry file could not be found #277

Closed shinchley closed 6 years ago

shinchley commented 6 years ago

When a registry file could not be found, the script caused a Traceback to be dumped to results log:

*** ServiceRoot -> Registries.Registries -> Members.MessageRegistryFile#1 -> Uri.Uri, /redfish/v1/RegistryStore/registries/en/XXX.json/

*** /redfish/v1/RegistryStore/registries/en/XXX.json/

* None, False, False chkauth header update: not noauthck=False and inService=True and UseSSL=True successauthchk callingResourceURI with authtype Session and ssl True: /redfish/v1/RegistryStore/registries/en/XXX.json {'OData-Version': '4.0', 'X-Auth-Token': '2eed8a18d6e932544f8e58a6ed0f2ace'} 200, [200], {'Connection': 'keep-alive', 'Server': 'nginx/1.10.3 (Ubuntu)', 'Link': '</redfish/v1/SchemaStore/en/MessageRegistryFileCollection.json/>; rel=describedby', 'Content-Length': '2041', 'Allow': 'GET, OPTIONS', 'Date': 'Thu, 05 May 2016 06:48:31 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Type': 'application/json', 'Vary': 'Accept'}, TIME ELAPSED: 0.121053 This is a JSON response A problem when getting resource has occurred /redfish/v1/RegistryStore/registries/en/XXX.json output: Traceback (most recent call last): File "/root/Redfish-Service-Validator-master/traverseService.py", line 357, in callResourceURI decoded = response.json(object_pairs_hook=OrderedDict) File "/usr/lib/python3.4/site-packages/requests/models.py", line 884, in json self.content.decode(encoding), kwargs File "/usr/lib64/python3.4/json/init.py", line 331, in loads return cls(**kw).decode(s) File "/usr/lib64/python3.4/json/decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python3.4/json/decoder.py", line 359, in raw_decode obj, end = self.scan_once(s, idx) ValueError: Expecting property name enclosed in double quotes: line 40 column 5 (char 1874) Creating ResourceObject ServiceRoot -> Registries.Registries -> Members.MessageRegistryFile#1 -> Uri.Uri /redfish/v1/RegistryStore/registries/en/XXX.json/ None False, None, 200 /redfish/v1/RegistryStore/registries/en/XXX.json/: URI could not be acquired: 200 Uri.Uri, Counter({'problemResource': 1}) Members.MessageRegistryFile#1, Counter({'pass': 6, 'skipOptional': 4, 'failMandatoryExist': 1, 'unvalidated': 1, 'err.Edm.String': 1, 'passGet': 1})

The trace back is then reported on the 'Show Results' page

billdodd commented 6 years ago

From the snippet above, it looks like the response from the GET to /redfish/v1/RegistryStore/registries/en/XXX.json returned a 200 status with an "application/json" Content-Type header. But it appears the content was not actually JSON.

So you may want to look at exactly what the service is returning from that URI.

For the tool, it probably makes sense for us to wrap the call to decoded = response.json() in a try block and log an appropriate error on exception (but avoid dumping the traceback into the report).

billdodd commented 6 years ago

I tried to reproduce this using a mockup, but I'm not getting the same results as you. In particular, I am not seeing the Traceback being reported in the HTML report.

The code in callResourceURI() is already catching exceptions during the parsing (or attempted parsing) of the payload and reporting an error in the HTML report. But the Traceback is only being logged in the .txt log file and not in the HTML report. This is the expected behavior.

@shinchley - can you rerun the test with the --debug_logging option and zip up the log files (.txt and .html) and attach them here. I'll take a look and see what is different from what I am seeing.

billdodd commented 6 years ago

@shinchley - any update on the logs I requested above?

billdodd commented 6 years ago

@shinchley - thanks for sending the logs. I'm submitting a PR to update the code emit a better error message in the HTML report (will include the type of exception and the error message). But will NOT show the traceback. The traceback will be available in the *.txt log if --debug_logging is enabled.