Add error checking into entry_id.py for input attributes dictionary for values that are None?
- Dominant language
- Python
- Stars
- 174
- Forks
- 225
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 14
Description
We ran into this problem in CMEPS (https://github.com/ESCOMP/CMEPS/issues/520) which was hard to figure out, because there wasn't error checking in place in cime, for an attribute being set to None. Adding some error checking would help users and developers identify the problem easier.
I added the following code to track down the problem. What's below is overkill, but I would cut it back to something reasonable. I think it would also be helpful if there was a DEBUG level logging on the check if attribute is not in attributes as that's likely a problem with the XML file being read in.
``` diff
diff --git a/CIME/XML/entry_id.py b/CIME/XML/entry_id.py
index c090a3633..930b613d3 100644
--- a/CIME/XML/entry_id.py
+++ b/CIME/XML/entry_id.py
@@ -127,11 +127,24 @@ def _get_value_match(
score = -1
break
else:
- if attribute not in attributes or not re.search(
- self.get(vnode, attribute), attributes[attribute]
- ):
+ if attribute not in attributes:
score = -1
break
+ else:
+ expect(isinstance(attribute,str), "attribute is NOT a string:"+str(attribute))
+ if attributes.get(attribute) == None:
+ print( "attribute is NOT in the attributes dictionary:"+str(attribute) )
+ print( "attributes dictionary:"+str(attributes) )
+ print( "filename:"+str(self.filename) )
+ print( "groups:"+str(self.groups) )
+ else:
+ expect(isinstance(attributes[attribute],str), "attribute from the attributes dictionary does NOT return a string:"+str(attribute))
+
+ if not re.search(
+ self.get(vnode, attribute), attributes[attribute]
+ ):
+ score = -1
+ break
# Add valid matches to the list.
if score >= 0:
```
Contributor guide
Assessment
This issue has not been assessed yet.