Skip to content

Commit

Permalink
Merge pull request #565 from DMTF/Fix564-Schema-Crashes
Browse files Browse the repository at this point in the history
Added exception handling when traversing links if the schema definition for the link is invalid
  • Loading branch information
mraineri committed Oct 6, 2023
2 parents 8347a00 + bf29bd2 commit 1865466
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ When validating a resource, the following types of tests may occur for each prop
* For object properties, check the properties inside the object againt the object's schema definition.
* For links, check that the URI referenced matches the expected resource type.

CSDL syntax errors will cause testing to halt and move on to other resources.
The OData CSDL Validator (https://github.com/DMTF/Redfish-Tools/tree/main/odata-csdl-validator) can be used to identify schema errors prior to testing.

## Conformance Logs - Summary and Detailed Conformance Report

The Redfish Service Validator generates an HTML report under the 'logs' folder and is named as 'ConformanceHtmlLog_MM_DD_YYYY_HHMMSS.html', along with a text and config file.
Expand All @@ -144,7 +147,7 @@ The Redfish Service Validator only performs GET operations on the service.
Below are certain items that are not in scope for the tool.

* Other HTTP methods, such as PATCH, are not covered.
* Wuery parameters, such as $top and $skip, are not covered.
* Query parameters, such as $top and $skip, are not covered.
* Multiple services are not tested simultaneously.

## Building a Standalone Windows Executable
Expand Down
19 changes: 11 additions & 8 deletions redfish_service_validator/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,14 +1101,17 @@ def getLinks(self):
if isinstance(item.Value, list):
for num, val in enumerate(item.Value):
# TODO: Along with example Excerpt and RedfishObject, replace following code with hypothetical RedfishType.getCollectionType
new_type_obj = item.Type.getCollectionType()
new_link = RedfishObject(new_type_obj, item.Name, item.parent).populate(val)
new_link.Name = new_link.Name + '#{}'.format(num)
if item.Type.AutoExpand:
new_link.IsAutoExpanded = True
if item.Type.Excerpt:
new_link.IsExcerpt = True
links.append(new_link)
try:
new_type_obj = item.Type.getCollectionType()
new_link = RedfishObject(new_type_obj, item.Name, item.parent).populate(val)
new_link.Name = new_link.Name + '#{}'.format(num)
if item.Type.AutoExpand:
new_link.IsAutoExpanded = True
if item.Type.Excerpt:
new_link.IsExcerpt = True
links.append(new_link)
except Exception as e:
my_logger.error('Unable to build definition for URI {}; check its schema definition or the schema making the reference to the URI for schema errors: {}'.format(val, repr(e)))
else:
links.append(item)
elif item.Type.getBaseType() == 'complex':
Expand Down
2 changes: 1 addition & 1 deletion redfish_service_validator/validateResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def validateSingleURI(service, URI, uriName='', expectedType=None, expectedJson=
raise # re-raise exception
except Exception as e:
my_logger.verbose1('Exception caught while creating ResourceObj', exc_info=1)
my_logger.error('Unable to gather property info for URI {}: {}'.format(URI, repr(e)))
my_logger.error('Unable to gather property info from schema for URI {}; check its schema definition for schema errors: {}'.format(URI, repr(e)))
counts['exceptionResource'] += 1
me['warns'], me['errors'] = get_my_capture(my_logger, whandler), get_my_capture(my_logger, ehandler)
return False, counts, results, None, None
Expand Down

0 comments on commit 1865466

Please sign in to comment.