Closed stianaske closed 3 years ago
@Santobert Do you agree with proposed fixes?
timezone
is not documented at all we shouldn't be too restrictive here. Let's use the following ROBOT_SCHEMA
ROBOT_SCHEMA = Schema(
{
Required("serial"): str,
"prefix": Any(str, None),
Required("name"): str,
"model": str,
Required("secret_key"): str,
"purchased_at": Any(str, None),
"linked_at": Any(str, None),
Required("traits"): list,
# Everything below this line is not documented, but still present
"firmware": Any(str, None),
"timezone": Any(str, None),
Required("nucleo_url"): Url,
"mac_address": Any(str, None),
"created_at": Any(str, None),
},
extra=ALLOW_EXTRA,
)
We could do same with MAPS_SCHEMA
and PERSISTENT_MAP_SCHEMA
and allow None
for non required fields as well.
Required()
fields are present at all and then if the field has the expected typing. So we can't distinguish between critical and less critical errors this way. Let's stay binary here. Either we can work with the given response or not. I can file a PR if you agree
Issue
Running the latest commit (34b5941), I am unable to list any robots because the response verification fails.
Steps to recreate
Running
on my account prints the following
and the for loop returns.
Explanation
The reason for this appears to be that
self._robots.add(robot_object)
is being skipped if response verification throws inrefresh_robots()
in account.py, regardless of whether the exception is due to a required or non-required field missmatch:Proposed fixes
ROBOT_SCHEMA
should allowNone
as timezone entry