Skip to content

Commit 8a9d59b

Browse files
committed
Code review 3
1 parent 3444245 commit 8a9d59b

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/datadog/remote_config.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ void RemoteConfigurationManager::process_response(const nlohmann::json& json) {
169169

170170
if (target_it == target_files.cend()) {
171171
state_.error_message =
172-
"Missing configuration from Remote Configuration response";
172+
"Missing configuration from Remote Configuration response: No "
173+
"target file having path \"";
174+
append(*state_.error_message, config_path);
175+
*state_.error_message += '\"';
173176
return;
174177
}
175178

test/test_remote_config.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,55 +85,55 @@ REMOTE_CONFIG_TEST("response processing") {
8585
R"({ "targets": "eyJmb28iOiAiYmFyIn0=" })",
8686
// `targets` is missing the `targets` field.
8787
// decode("eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAiY3VzdG9tIjogeyJvcGFxdWVfYmFja2VuZF9zdGF0ZSI6ICIxNSJ9fX0=") == "{"signed": {"version": 2, "custom": {"opaque_backend_state": "15"}}}"
88-
R"({
88+
R"({
8989
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAiY3VzdG9tIjogeyJvcGFxdWVfYmFja2VuZF9zdGF0ZSI6ICIxNSJ9fX0=",
9090
"client_configs": ["datadog"]
9191
})",
9292
// `/targets/targets` have no `datadog` entry
9393
// {"signed": {"version": 2, "targets": {"foo": {}, "bar": {}},"custom": {"opaque_backend_state": "15"}}}
94-
R"({
94+
R"({
9595
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAidGFyZ2V0cyI6IHsiZm9vIjoge30sICJiYXIiOiB7fX0sImN1c3RvbSI6IHsib3BhcXVlX2JhY2tlbmRfc3RhdGUiOiAiMTUifX19",
9696
"client_configs": ["datadog"]
9797
})",
9898
// `targets` OK but no `target_files` field.
9999
// {"signed": {"version": 2, "targets": {"foo/APM_TRACING/30": {}, "bar": {}},"custom": {"opaque_backend_state": "15"}}}
100-
R"({
100+
R"({
101101
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAidGFyZ2V0cyI6IHsiZm9vL0FQTV9UUkFDSU5HLzMwIjoge30sICJiYXIiOiB7fX0sImN1c3RvbSI6IHsib3BhcXVlX2JhY2tlbmRfc3RhdGUiOiAiMTUifX19",
102102
"client_configs": ["foo/APM_TRACING/30"]
103103
})",
104104
// `targets` OK. `target_files` field is empty.
105105
// {"signed": {"version": 2, "targets": {"foo/APM_TRACING/30": {}, "bar": {}},"custom": {"opaque_backend_state": "15"}}}
106-
R"({
106+
R"({
107107
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAidGFyZ2V0cyI6IHsiZm9vL0FQTV9UUkFDSU5HLzMwIjoge30sICJiYXIiOiB7fX0sImN1c3RvbSI6IHsib3BhcXVlX2JhY2tlbmRfc3RhdGUiOiAiMTUifX19",
108108
"client_configs": ["foo/APM_TRACING/30"],
109109
"target_files": []
110110
})",
111111
// `targets` OK. `target_files` field is not an array.
112112
// {"signed": {"version": 2, "targets": {"foo/APM_TRACING/30": {}, "bar": {}},"custom": {"opaque_backend_state": "15"}}}
113-
R"({
113+
R"({
114114
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAidGFyZ2V0cyI6IHsiZm9vL0FQTV9UUkFDSU5HLzMwIjoge30sICJiYXIiOiB7fX0sImN1c3RvbSI6IHsib3BhcXVlX2JhY2tlbmRfc3RhdGUiOiAiMTUifX19",
115115
"client_configs": ["foo/APM_TRACING/30"],
116116
"target_files": 15
117117
})",
118118
// `targets` OK. `target_files` field content is not base64 encoded.
119119
// {"signed": {"version": 2, "targets": {"foo/APM_TRACING/30": {}, "bar": {}},"custom": {"opaque_backend_state": "15"}}}
120-
R"({
120+
R"({
121121
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAidGFyZ2V0cyI6IHsiZm9vL0FQTV9UUkFDSU5HLzMwIjoge30sICJiYXIiOiB7fX0sImN1c3RvbSI6IHsib3BhcXVlX2JhY2tlbmRfc3RhdGUiOiAiMTUifX19",
122122
"client_configs": ["foo/APM_TRACING/30"],
123123
"target_files": [{"path": "foo/APM_TRACING/30", "raw": "Hello, Uranus!"}]
124124
})",
125125
// `targets` OK. `target_files` field content is not a JSON base64 encoded.
126126
// decode("bm90IGpzb24=") == "not json"
127127
// {"signed": {"version": 2, "targets": {"foo/APM_TRACING/30": {}, "bar": {}},"custom": {"opaque_backend_state": "15"}}}
128-
R"({
128+
R"({
129129
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAidGFyZ2V0cyI6IHsiZm9vL0FQTV9UUkFDSU5HLzMwIjoge30sICJiYXIiOiB7fX0sImN1c3RvbSI6IHsib3BhcXVlX2JhY2tlbmRfc3RhdGUiOiAiMTUifX19",
130130
"client_configs": ["foo/APM_TRACING/30"],
131131
"target_files": [{"path": "foo/APM_TRACING/30", "raw": "bm90IGpzb24="}]
132132
})",
133133
// `targets` OK. `target_files` field JSON base64 content do not follow the expected schema.
134134
// decode("eyJmb28iOiAiYmFyIn0=") == "{"foo": "bar"}"
135135
// {"signed": {"version": 2, "targets": {"foo/APM_TRACING/30": {}, "bar": {}},"custom": {"opaque_backend_state": "15"}}}
136-
R"({
136+
R"({
137137
"targets": "eyJzaWduZWQiOiB7InZlcnNpb24iOiAyLCAidGFyZ2V0cyI6IHsiZm9vL0FQTV9UUkFDSU5HLzMwIjoge30sICJiYXIiOiB7fX0sImN1c3RvbSI6IHsib3BhcXVlX2JhY2tlbmRfc3RhdGUiOiAiMTUifX19",
138138
"client_configs": ["foo/APM_TRACING/30"],
139139
"target_files": [{"path": "foo/APM_TRACING/30", "raw": "eyJmb28iOiAiYmFyIn0="}]

0 commit comments

Comments
 (0)