Fix 'None' field value processing
Change [1] introduced a conditional call to Field's "adapter" callable supposedly to work-around some OEM issues. Sadly, the exact problem that change [1] has been trying to solve was never explained and remains murky. However, fix [1] has also introduced a bug which makes sushy ignoring 'None' literals in the values. This sometimes leads to sushy failing to operate on perfectly valid JSON documents. This change removes most of the conditions guarding Field's "adapter" function calls. 1. https://review.opendev.org/#/c/669963/6 Change-Id: I8d1e1691a0bb2b6315894c85569a73633d34c1cb
This commit is contained in:
parent
544f000fe6
commit
1ec13aaba2
|
@ -101,16 +101,12 @@ class Field(object):
|
||||||
# Do not run the adapter on the default value
|
# Do not run the adapter on the default value
|
||||||
return self._default
|
return self._default
|
||||||
|
|
||||||
try:
|
# NOTE(etingof): this is just to account for schema violation
|
||||||
# Get the value based on the name, defaulting to an empty dict
|
if item is None:
|
||||||
# Check to ensure that value is implemented by OEM
|
return
|
||||||
# TODO(etingof): we should revisit this logic/code
|
|
||||||
if (item is not None and item != {} and
|
|
||||||
str(item).lower() != 'none'):
|
|
||||||
value = self._adapter(item)
|
|
||||||
|
|
||||||
else:
|
try:
|
||||||
value = item
|
return self._adapter(item)
|
||||||
|
|
||||||
except (UnicodeError, ValueError, TypeError) as exc:
|
except (UnicodeError, ValueError, TypeError) as exc:
|
||||||
path = (nested_in or []) + self._path
|
path = (nested_in or []) + self._path
|
||||||
|
@ -119,8 +115,6 @@ class Field(object):
|
||||||
resource=resource.path,
|
resource=resource.path,
|
||||||
error=exc)
|
error=exc)
|
||||||
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def _collect_fields(resource):
|
def _collect_fields(resource):
|
||||||
"""Collect fields from the JSON.
|
"""Collect fields from the JSON.
|
||||||
|
|
Loading…
Reference in New Issue