New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AGENT-65 and AGENT-66 - Broken unit test (json encoding) #160
Conversation
Need you guys' input on this @czerwingithub @imron . Particularly because the failing test pertains to |
I talked with Steven. Here's the summary:
|
_json_encode = dumps_no_space | ||
_json_decode = json.loads | ||
return lib_name, json_dumps_custom, json.loads | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone passes in a lib_name
value that is not json
ujson
or json_lib
(for whatever reason, maybe a spelling mistake, or maybe a new json library is added), then the function will reach the end and return None
, instead of an expected 3-value tuple.
It's not a big issue, because it'll probably never happen and if it does we'll get a compile error, but maybe if we get an unrecognized name then we raise an exception with a message that the json lib_name
is unsupported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good suggestion. Change has been made & unit test installed to capture.
TestLogFileProcessor.test_log_attributes
sort_keys
Error for (1) is
ANALYSIS
scalyr_agent.util.json_encode
does not know how to encode our customJsonArray
andJsonObject
by default, if the underlying lib isjson
orujson
. (If the underlying lib is the fallbackjson_lib
, we're OK)Furthermore, if underlying is
json
, we get the loudTypeError
as above. But if underlying isujson
,json_encode()
insiduously does not raise exception but encodes incorrectlySTATUS
Per discussion with Steven, I have:
LogFileProcessor
to raise exception if you incorrectly pass in a JsonArray/Object