-
Notifications
You must be signed in to change notification settings - Fork 197
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
MEN-6834: Make all JSON parsing case insensitive #1523
MEN-6834: Make all JSON parsing case insensitive #1523
Conversation
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
@lluiscampos, Let me know if you want to start the integration pipeline by mentioning me and the command "start pipeline". my commands and optionsYou can trigger a pipeline on multiple prs with:
You can start a fast pipeline, disabling full integration tests with:
You can trigger GitHub->GitLab branch sync with:
You can cherry pick to a given branch or branches with:
|
6f0a11b
to
e31bd2c
Compare
template <class Key, class T, class IgnoredLess, class Allocator = allocator<pair<const Key, T>>> | ||
class CaseInsensitiveMap : public map<const Key, T, CaseInsensitiveLess, Allocator> { | ||
public: | ||
using CaseInsensitiveMapType = map<const Key, T, CaseInsensitiveLess, Allocator>; |
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.
@mender-test-bot start pipeline |
Hello 😸 I created a pipeline for you here: Pipeline-1089545281 Build Configuration Matrix
|
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.
Nice!
os << R"({ | ||
"artifactverifykey": "ArtifactVerifyKey_value", | ||
"deviceTypeFile": "DeviceTypeFile_value", | ||
"SERVERURL": "ServerURL_value" |
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.
Maybe we should have a separate test where you have the same key with different casing? I'm a little bit interested to see how it handles it, especially when compared to having two completely identical keys.
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.
It behaves the same with two identical keys than with same key with different casing: the entry in the map gets overridden and only the last one stands.
I'll add a test, thanks for the suggestion.
Although the JSON standard defines the keys as case sensitive, the golang standard library implements it as case insensitive. Therefore to avoid regressions we need to make all our JSON parsing case insensitive. To implement it, we define a custom `nlohmann::basic_json` with a custom `std::map` that compares the keys as lowercase. See: * https://json.nlohmann.me/api/basic_json/basic_json/ * https://json.nlohmann.me/api/basic_json/object_t/ Ticket: MEN-6834 Changelog: None Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
e31bd2c
to
cb118d4
Compare
The last force-push only added a unit-test, not running again the full pipeline. See the last pipeline here. |
Although the JSON standard defines the keys as case sensitive, the
golang standard library implements it as case insensitive. Therefore to
avoid regressions we need to make all our JSON parsing case insensitive.
To implement it, we define a custom
nlohmann::basic_json
with a customstd::map
that compares the keys as lowercase. See: