Skip to content

Commit 1865466

Browse files
authored
Merge pull request #565 from DMTF/Fix564-Schema-Crashes
Added exception handling when traversing links if the schema definition for the link is invalid
2 parents 8347a00 + bf29bd2 commit 1865466

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ When validating a resource, the following types of tests may occur for each prop
123123
* For object properties, check the properties inside the object againt the object's schema definition.
124124
* For links, check that the URI referenced matches the expected resource type.
125125

126+
CSDL syntax errors will cause testing to halt and move on to other resources.
127+
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.
128+
126129
## Conformance Logs - Summary and Detailed Conformance Report
127130

128131
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.
@@ -144,7 +147,7 @@ The Redfish Service Validator only performs GET operations on the service.
144147
Below are certain items that are not in scope for the tool.
145148

146149
* Other HTTP methods, such as PATCH, are not covered.
147-
* Wuery parameters, such as $top and $skip, are not covered.
150+
* Query parameters, such as $top and $skip, are not covered.
148151
* Multiple services are not tested simultaneously.
149152

150153
## Building a Standalone Windows Executable

redfish_service_validator/catalog.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,14 +1101,17 @@ def getLinks(self):
11011101
if isinstance(item.Value, list):
11021102
for num, val in enumerate(item.Value):
11031103
# TODO: Along with example Excerpt and RedfishObject, replace following code with hypothetical RedfishType.getCollectionType
1104-
new_type_obj = item.Type.getCollectionType()
1105-
new_link = RedfishObject(new_type_obj, item.Name, item.parent).populate(val)
1106-
new_link.Name = new_link.Name + '#{}'.format(num)
1107-
if item.Type.AutoExpand:
1108-
new_link.IsAutoExpanded = True
1109-
if item.Type.Excerpt:
1110-
new_link.IsExcerpt = True
1111-
links.append(new_link)
1104+
try:
1105+
new_type_obj = item.Type.getCollectionType()
1106+
new_link = RedfishObject(new_type_obj, item.Name, item.parent).populate(val)
1107+
new_link.Name = new_link.Name + '#{}'.format(num)
1108+
if item.Type.AutoExpand:
1109+
new_link.IsAutoExpanded = True
1110+
if item.Type.Excerpt:
1111+
new_link.IsExcerpt = True
1112+
links.append(new_link)
1113+
except Exception as e:
1114+
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)))
11121115
else:
11131116
links.append(item)
11141117
elif item.Type.getBaseType() == 'complex':

redfish_service_validator/validateResource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def validateSingleURI(service, URI, uriName='', expectedType=None, expectedJson=
116116
raise # re-raise exception
117117
except Exception as e:
118118
my_logger.verbose1('Exception caught while creating ResourceObj', exc_info=1)
119-
my_logger.error('Unable to gather property info for URI {}: {}'.format(URI, repr(e)))
119+
my_logger.error('Unable to gather property info from schema for URI {}; check its schema definition for schema errors: {}'.format(URI, repr(e)))
120120
counts['exceptionResource'] += 1
121121
me['warns'], me['errors'] = get_my_capture(my_logger, whandler), get_my_capture(my_logger, ehandler)
122122
return False, counts, results, None, None

0 commit comments

Comments
 (0)