bugfix: failed send
could bury error message coming from ODS
#69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes an edge case that results in Lightbeam logging a Python error message instead of the ODS error message
Let's say you send an invalid payload and get a 400 response. I'm not sure exactly what changed (or when) on the ODS side, – it's possible this is only a problem in the local ODS I'm running – but the
do_post
function makes assumptions about the structure of the error response payload that don't always match what is returned.Currently:
"message"
to be a field in the response body, and passes its value tolinearize
:util.linearize(json.loads(body).get("message")
"message"
is not present in the body,linearize
throws aTypeError
when it tries to perform a string operation onNone
TypeError
gets caught bydo_post
's general exception catcher:except Exception
and gets logged as an ordinary errorThis change:
"message"
and"errors"
syntax coming from the ODS -"errors"
comes as a list of stringsException
to aValueError
to reduce the likelihood that a Python error will get caught and reportedAs I say, I don't know whether or when we'll see

"errors"
instead of"message"
in the wild, but it is at least possible under some of the packages Ed-Fi has published and it's otherwise harmless. In any case, not catching the genericException
is the deeper fix