• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender / 2291262117

28 Jan 2026 10:00AM UTC coverage: 81.518% (+0.04%) from 81.475%
2291262117

push

gitlab-ci

web-flow
Merge pull request #1892 from lluiscampos/fix-build

chore: Fix build after bad merge

2 of 2 new or added lines in 1 file covered. (100.0%)

169 existing lines in 5 files now uncovered.

8874 of 10886 relevant lines covered (81.52%)

20156.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.07
/src/mender-update/deployments/deployments.cpp
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
#include <mender-update/deployments.hpp>
16

17
#include <algorithm>
18
#include <sstream>
19
#include <string>
20

21
#include <api/api.hpp>
22
#include <api/client.hpp>
23
#include <common/common.hpp>
24
#include <common/error.hpp>
25
#include <common/events.hpp>
26
#include <common/expected.hpp>
27
#include <common/http.hpp>
28
#include <common/io.hpp>
29
#include <common/json.hpp>
30
#include <common/log.hpp>
31
#include <common/optional.hpp>
32
#include <mender-update/context.hpp>
33

34
namespace mender {
35
namespace update {
36
namespace deployments {
37

38
using namespace std;
39

40
namespace api = mender::api;
41
namespace common = mender::common;
42
namespace context = mender::update::context;
43
namespace error = mender::common::error;
44
namespace events = mender::common::events;
45
namespace expected = mender::common::expected;
46
namespace http = mender::common::http;
47
namespace io = mender::common::io;
48
namespace json = mender::common::json;
49
namespace log = mender::common::log;
50

51
const DeploymentsErrorCategoryClass DeploymentsErrorCategory;
52

53
const char *DeploymentsErrorCategoryClass::name() const noexcept {
×
54
        return "DeploymentsErrorCategory";
×
55
}
56

57
string DeploymentsErrorCategoryClass::message(int code) const {
17✔
58
        switch (code) {
17✔
59
        case NoError:
60
                return "Success";
×
61
        case InvalidDataError:
62
                return "Invalid data error";
×
63
        case BadResponseError:
64
                return "Bad response error";
4✔
65
        case DeploymentAbortedError:
66
                return "Deployment was aborted on the server";
3✔
67
        case TooManyRequestsError:
68
                return "Too many requests";
10✔
69
        }
70
        assert(false);
UNCOV
71
        return "Unknown";
×
72
}
73

74
error::Error MakeError(DeploymentsErrorCode code, const string &msg) {
34✔
75
        return error::Error(error_condition(code, DeploymentsErrorCategory), msg);
42✔
76
}
77

78
static const string check_updates_v1_uri = "/api/devices/v1/deployments/device/deployments/next";
79
static const string check_updates_v2_uri = "/api/devices/v2/deployments/device/deployments/next";
80

81
error::Error DeploymentClient::CheckNewDeployments(
10✔
82
        context::MenderContext &ctx, api::Client &client, CheckUpdatesAPIResponseHandler api_handler) {
83
        auto ex_compatible_type = ctx.GetCompatibleType();
20✔
84
        if (!ex_compatible_type) {
10✔
85
                return ex_compatible_type.error();
4✔
86
        }
87
        string compatible_type = ex_compatible_type.value();
6✔
88

89
        auto ex_provides = ctx.LoadProvides();
6✔
90
        if (!ex_provides) {
6✔
UNCOV
91
                return ex_provides.error();
×
92
        }
93
        auto provides = ex_provides.value();
6✔
94
        if (provides.find("artifact_name") == provides.end()) {
12✔
UNCOV
95
                return MakeError(InvalidDataError, "Missing artifact name data");
×
96
        }
97

98
        stringstream ss;
6✔
99
        ss << R"({"device_provides":{)";
6✔
100
        ss << R"("device_type":")";
6✔
101
        ss << json::EscapeString(compatible_type);
12✔
102

103
        for (const auto &kv : provides) {
14✔
104
                ss << "\",\"" + json::EscapeString(kv.first) + "\":\"";
8✔
105
                ss << json::EscapeString(kv.second);
16✔
106
        }
107

108
        ss << R"("}})";
6✔
109

110
        string v2_payload = ss.str();
111
        log::Debug("deployments/next v2 payload " + v2_payload);
6✔
112
        http::BodyGenerator payload_gen = [v2_payload]() {
54✔
113
                return make_shared<io::StringReader>(v2_payload);
6✔
114
        };
6✔
115

116
        auto v2_req = make_shared<api::APIRequest>();
6✔
117
        v2_req->SetPath(check_updates_v2_uri);
118
        v2_req->SetMethod(http::Method::POST);
6✔
119
        v2_req->SetHeader("Content-Type", "application/json");
12✔
120
        v2_req->SetHeader("Content-Length", to_string(v2_payload.size()));
12✔
121
        v2_req->SetHeader("Accept", "application/json");
12✔
122
        v2_req->SetBodyGenerator(payload_gen);
6✔
123

124
        string v1_args = "artifact_name=" + http::URLEncode(provides["artifact_name"])
12✔
125
                                         + "&device_type=" + http::URLEncode(compatible_type);
18✔
126
        auto v1_req = make_shared<api::APIRequest>();
6✔
127
        v1_req->SetPath(check_updates_v1_uri + "?" + v1_args);
6✔
128
        v1_req->SetMethod(http::Method::GET);
6✔
129
        v1_req->SetHeader("Accept", "application/json");
12✔
130

131
        auto received_body = make_shared<vector<uint8_t>>();
6✔
132
        auto handle_data = [received_body, api_handler](unsigned status) {
4✔
133
                if (status == http::StatusOK) {
4✔
134
                        auto ex_j = json::Load(common::StringFromByteVector(*received_body));
4✔
135
                        if (ex_j) {
2✔
136
                                CheckUpdatesAPIResponse response {optional<json::Json> {ex_j.value()}};
2✔
137
                                api_handler(response);
4✔
138
                        } else {
UNCOV
139
                                api_handler(expected::unexpected(
×
UNCOV
140
                                        CheckUpdatesAPIResponseError {status, nullopt, ex_j.error()}));
×
141
                        }
142
                } else if (status == http::StatusNoContent) {
2✔
143
                        api_handler(CheckUpdatesAPIResponse {nullopt});
4✔
144
                } else {
145
                        log::Warning(
×
146
                                "DeploymentClient::CheckNewDeployments - received unhandled http response: "
UNCOV
147
                                + to_string(status));
×
UNCOV
148
                        api_handler(expected::unexpected(CheckUpdatesAPIResponseError {
×
149
                                status,
150
                                nullopt,
151
                                MakeError(
152
                                        DeploymentAbortedError,
153
                                        "received unhandled HTTP response: " + to_string(status))}));
×
154
                }
155
        };
10✔
156

157
        http::ResponseHandler header_handler =
158
                [this, received_body, api_handler](http::ExpectedIncomingResponsePtr exp_resp) {
12✔
159
                        this->HeaderHandler(received_body, api_handler, exp_resp);
27✔
160
                };
15✔
161

162
        http::ResponseHandler v1_body_handler =
163
                [received_body, api_handler, handle_data](http::ExpectedIncomingResponsePtr exp_resp) {
15✔
164
                        if (!exp_resp) {
3✔
UNCOV
165
                                log::Error("Request to check new deployments failed: " + exp_resp.error().message);
×
UNCOV
166
                                CheckUpdatesAPIResponse response = expected::unexpected(
×
UNCOV
167
                                        CheckUpdatesAPIResponseError {nullopt, nullopt, exp_resp.error()});
×
UNCOV
168
                                api_handler(response);
×
169
                                return;
170
                        }
171
                        auto resp = exp_resp.value();
3✔
172
                        auto status = resp->GetStatusCode();
3✔
173

174
                        // StatusTooManyRequests must have been handled in HeaderHandler already
175
                        assert(status != http::StatusTooManyRequests);
176

177
                        if ((status == http::StatusOK) || (status == http::StatusNoContent)) {
3✔
178
                                handle_data(status);
2✔
179
                        } else {
180
                                auto ex_err_msg = api::ErrorMsgFromErrorResponse(*received_body);
1✔
181
                                string err_str;
182
                                if (ex_err_msg) {
1✔
UNCOV
183
                                        err_str = ex_err_msg.value();
×
184
                                } else {
185
                                        err_str = resp->GetStatusMessage();
2✔
186
                                }
187
                                api_handler(expected::unexpected(CheckUpdatesAPIResponseError {
3✔
188
                                        status,
189
                                        nullopt,
190
                                        MakeError(
191
                                                BadResponseError,
192
                                                "Got unexpected response " + to_string(status) + ": " + err_str)}));
2✔
193
                        }
194
                };
6✔
195

196
        http::ResponseHandler v2_body_handler = [received_body,
18✔
197
                                                                                         v1_req,
198
                                                                                         header_handler,
199
                                                                                         v1_body_handler,
200
                                                                                         api_handler,
201
                                                                                         handle_data,
202
                                                                                         &client](http::ExpectedIncomingResponsePtr exp_resp) {
203
                if (!exp_resp) {
6✔
UNCOV
204
                        log::Error("Request to check new deployments failed: " + exp_resp.error().message);
×
UNCOV
205
                        CheckUpdatesAPIResponse response = expected::unexpected(
×
UNCOV
206
                                CheckUpdatesAPIResponseError {nullopt, nullopt, exp_resp.error()});
×
UNCOV
207
                        api_handler(response);
×
208
                        return;
209
                }
210
                auto resp = exp_resp.value();
6✔
211
                auto status = resp->GetStatusCode();
6✔
212

213
                // StatusTooManyRequests must have been handled in HeaderHandler already
214
                assert(status != http::StatusTooManyRequests);
215

216
                if ((status == http::StatusOK) || (status == http::StatusNoContent)) {
6✔
217
                        handle_data(status);
2✔
218
                } else if (status == http::StatusNotFound) {
4✔
219
                        log::Debug(
3✔
220
                                "POST request to v2 version of the deployments API failed, falling back to v1 version and GET");
221
                        auto err = client.AsyncCall(v1_req, header_handler, v1_body_handler);
9✔
222
                        if (err != error::NoError) {
3✔
UNCOV
223
                                api_handler(expected::unexpected(CheckUpdatesAPIResponseError {
×
UNCOV
224
                                        status, nullopt, err.WithContext("While calling v1 endpoint")}));
×
225
                        }
226
                } else {
227
                        auto ex_err_msg = api::ErrorMsgFromErrorResponse(*received_body);
1✔
228
                        string err_str;
229
                        if (ex_err_msg) {
1✔
230
                                err_str = ex_err_msg.value();
1✔
231
                        } else {
UNCOV
232
                                err_str = resp->GetStatusMessage();
×
233
                        }
234
                        api_handler(expected::unexpected(CheckUpdatesAPIResponseError {
3✔
235
                                status,
236
                                nullopt,
237
                                MakeError(
238
                                        BadResponseError,
239
                                        "Got unexpected response " + to_string(status) + ": " + err_str)}));
2✔
240
                }
241
        };
6✔
242

243
        return client.AsyncCall(v2_req, header_handler, v2_body_handler);
18✔
244
}
12✔
245

246
void DeploymentClient::HeaderHandler(
12✔
247
        shared_ptr<vector<uint8_t>> received_body,
248
        CheckUpdatesAPIResponseHandler api_handler,
249
        http::ExpectedIncomingResponsePtr exp_resp) {
250
        if (!exp_resp) {
12✔
UNCOV
251
                log::Error("Request to check new deployments failed: " + exp_resp.error().message);
×
252
                CheckUpdatesAPIResponse response =
UNCOV
253
                        expected::unexpected(CheckUpdatesAPIResponseError {nullopt, nullopt, exp_resp.error()});
×
UNCOV
254
                api_handler(response);
×
255
                return;
256
        }
257

258
        auto resp = exp_resp.value();
12✔
259
        auto status = resp->GetStatusCode();
12✔
260
        if (status == http::StatusTooManyRequests) {
12✔
261
                CheckUpdatesAPIResponse response = expected::unexpected(CheckUpdatesAPIResponseError {
6✔
262
                        status, resp->GetHeaders(), MakeError(TooManyRequestsError, "Too many requests")});
9✔
263
                api_handler(response);
6✔
264
                return;
265
        }
266
        received_body->clear();
9✔
267
        auto body_writer = make_shared<io::ByteWriter>(received_body);
9✔
268
        body_writer->SetUnlimited(true);
9✔
269
        resp->SetBodyWriter(body_writer);
18✔
270
}
271

272
static const string deployment_status_strings[static_cast<int>(DeploymentStatus::End_) + 1] = {
273
        "installing",
274
        "pause_before_installing",
275
        "downloading",
276
        "pause_before_rebooting",
277
        "rebooting",
278
        "pause_before_committing",
279
        "success",
280
        "failure",
281
        "already-installed"};
282

283
static const string deployments_uri_prefix = "/api/devices/v1/deployments/device/deployments";
284
static const string status_uri_suffix = "/status";
285

286
string DeploymentStatusString(DeploymentStatus status) {
501✔
287
        return deployment_status_strings[static_cast<int>(status)];
505✔
288
}
289

290
error::Error DeploymentClient::PushStatus(
4✔
291
        const string &deployment_id,
292
        DeploymentStatus status,
293
        const string &substate,
294
        api::Client &client,
295
        StatusAPIResponseHandler api_handler) {
296
        // Cannot push a status update without a deployment ID
297
        AssertOrReturnError(deployment_id != "");
4✔
298
        string payload = R"({"status":")" + DeploymentStatusString(status) + "\"";
4✔
299
        if (substate != "") {
4✔
300
                payload += R"(,"substate":")" + json::EscapeString(substate) + "\"}";
6✔
301
        } else {
302
                payload += "}";
1✔
303
        }
304
        http::BodyGenerator payload_gen = [payload]() {
36✔
305
                return make_shared<io::StringReader>(payload);
4✔
306
        };
4✔
307

308
        auto req = make_shared<api::APIRequest>();
4✔
309
        req->SetPath(http::JoinUrl(deployments_uri_prefix, deployment_id, status_uri_suffix));
4✔
310
        req->SetMethod(http::Method::PUT);
4✔
311
        req->SetHeader("Content-Type", "application/json");
8✔
312
        req->SetHeader("Content-Length", to_string(payload.size()));
8✔
313
        req->SetHeader("Accept", "application/json");
8✔
314
        req->SetBodyGenerator(payload_gen);
4✔
315

316
        auto received_body = make_shared<vector<uint8_t>>();
4✔
317
        return client.AsyncCall(
16✔
318
                req,
319
                [received_body, api_handler](http::ExpectedIncomingResponsePtr exp_resp) {
12✔
320
                        if (!exp_resp) {
4✔
UNCOV
321
                                log::Error("Request to push status data failed: " + exp_resp.error().message);
×
UNCOV
322
                                api_handler(exp_resp.error());
×
UNCOV
323
                                return;
×
324
                        }
325

326
                        auto body_writer = make_shared<io::ByteWriter>(received_body);
4✔
327
                        auto resp = exp_resp.value();
4✔
328
                        auto content_length = resp->GetHeader("Content-Length");
8✔
329
                        if (!content_length) {
4✔
UNCOV
330
                                log::Debug(
×
331
                                        "Failed to get content length from the status API response headers: "
UNCOV
332
                                        + content_length.error().String());
×
UNCOV
333
                                body_writer->SetUnlimited(true);
×
334
                        } else {
335
                                auto ex_len = common::StringTo<size_t>(content_length.value());
4✔
336
                                if (!ex_len) {
4✔
UNCOV
337
                                        log::Error(
×
338
                                                "Failed to convert the content length from the status API response headers to an integer: "
UNCOV
339
                                                + ex_len.error().String());
×
UNCOV
340
                                        body_writer->SetUnlimited(true);
×
341
                                } else {
342
                                        received_body->resize(ex_len.value());
4✔
343
                                }
344
                        }
345
                        resp->SetBodyWriter(body_writer);
8✔
346
                },
347
                [received_body, api_handler](http::ExpectedIncomingResponsePtr exp_resp) {
12✔
348
                        if (!exp_resp) {
4✔
UNCOV
349
                                log::Error("Request to push status data failed: " + exp_resp.error().message);
×
UNCOV
350
                                api_handler(exp_resp.error());
×
UNCOV
351
                                return;
×
352
                        }
353

354
                        auto resp = exp_resp.value();
4✔
355
                        auto status = resp->GetStatusCode();
4✔
356
                        if (status == http::StatusNoContent) {
4✔
357
                                api_handler(error::NoError);
4✔
358
                        } else if (status == http::StatusConflict) {
2✔
359
                                api_handler(
1✔
360
                                        MakeError(DeploymentAbortedError, "Could not send status update to server"));
2✔
361
                        } else {
362
                                auto ex_err_msg = api::ErrorMsgFromErrorResponse(*received_body);
1✔
363
                                string err_str;
364
                                if (ex_err_msg) {
1✔
365
                                        err_str = ex_err_msg.value();
1✔
366
                                } else {
UNCOV
367
                                        err_str = resp->GetStatusMessage();
×
368
                                }
369
                                api_handler(MakeError(
1✔
370
                                        BadResponseError,
371
                                        "Got unexpected response " + to_string(status)
1✔
372
                                                + " from status API: " + err_str));
2✔
373
                        }
374
                });
4✔
375
}
376

377
using mender::common::expected::ExpectedSize;
378

379
static ExpectedSize GetLogFileDataSize(const string &path) {
3✔
380
        auto ex_istr = io::OpenIfstream(path);
3✔
381
        if (!ex_istr) {
3✔
UNCOV
382
                return expected::unexpected(ex_istr.error());
×
383
        }
384
        auto istr = std::move(ex_istr.value());
3✔
385

386
        // We want the size of the actual data without a potential trailing
387
        // newline. So let's seek one byte before the end of file, check if the last
388
        // byte is a newline and return the appropriate number.
389
        istr.seekg(-1, ios_base::end);
3✔
390
        int c = istr.get();
3✔
391
        if (c == '\n') {
3✔
392
                return istr.tellg() - static_cast<ifstream::off_type>(1);
3✔
393
        } else {
UNCOV
394
                return istr.tellg();
×
395
        }
396
}
3✔
397

398
const vector<uint8_t> JsonLogMessagesReader::header_ = {
399
        '{', '"', 'm', 'e', 's', 's', 'a', 'g', 'e', 's', '"', ':', '['};
400
const vector<uint8_t> JsonLogMessagesReader::closing_ = {']', '}'};
401

402
ExpectedSize JsonLogMessagesReader::Read(
89✔
403
        vector<uint8_t>::iterator start, vector<uint8_t>::iterator end) {
404
        if (header_rem_ > 0) {
89✔
405
                io::Vsize target_size = end - start;
9✔
406
                auto copy_end = copy_n(
9✔
407
                        header_.begin() + (header_.size() - header_rem_), min(header_rem_, target_size), start);
9✔
408
                auto n_copied = copy_end - start;
409
                header_rem_ -= n_copied;
9✔
410
                return static_cast<size_t>(n_copied);
411
        } else if (rem_raw_data_size_ > 0) {
80✔
412
                if (end - start > rem_raw_data_size_) {
64✔
413
                        end = start + static_cast<size_t>(rem_raw_data_size_);
414
                }
415
                auto ex_sz = reader_->Read(start, end);
64✔
416
                if (!ex_sz) {
64✔
417
                        return ex_sz;
418
                }
419
                auto n_read = ex_sz.value();
64✔
420
                rem_raw_data_size_ -= n_read;
64✔
421

422
                // We control how much we read from the file so we should never read
423
                // 0 bytes (meaning EOF reached). If we do, it means the file is
424
                // smaller than what we were told.
425
                assert(n_read > 0);
426
                if (n_read == 0) {
64✔
UNCOV
427
                        return expected::unexpected(
×
UNCOV
428
                                MakeError(InvalidDataError, "Unexpected EOF when reading logs file"));
×
429
                }
430

431
                // Replace all newlines with commas
432
                const auto read_end = start + n_read;
433
                for (auto it = start; it < read_end; it++) {
1,916✔
434
                        if (it[0] == '\n') {
1,852✔
435
                                it[0] = ',';
12✔
436
                        }
437
                }
438
                return n_read;
439
        } else if (closing_rem_ > 0) {
16✔
440
                io::Vsize target_size = end - start;
8✔
441
                auto copy_end = copy_n(
8✔
442
                        closing_.begin() + (closing_.size() - closing_rem_),
8✔
443
                        min(closing_rem_, target_size),
444
                        start);
445
                auto n_copied = copy_end - start;
446
                closing_rem_ -= n_copied;
8✔
447
                return static_cast<size_t>(copy_end - start);
448
        } else {
449
                return 0;
450
        }
451
};
452

453
static const string logs_uri_suffix = "/log";
454

455
error::Error DeploymentClient::PushLogs(
3✔
456
        const string &deployment_id,
457
        const string &log_file_path,
458
        api::Client &client,
459
        LogsAPIResponseHandler api_handler) {
460
        auto ex_size = GetLogFileDataSize(log_file_path);
3✔
461
        if (!ex_size) {
3✔
462
                // api_handler(ex_size.error()) ???
463
                return ex_size.error();
×
464
        }
465
        auto data_size = ex_size.value();
3✔
466

467
        auto file_reader = make_shared<io::FileReader>(log_file_path);
3✔
468
        auto logs_reader = make_shared<JsonLogMessagesReader>(file_reader, data_size);
3✔
469

470
        auto req = make_shared<api::APIRequest>();
3✔
471
        req->SetPath(http::JoinUrl(deployments_uri_prefix, deployment_id, logs_uri_suffix));
3✔
472
        req->SetMethod(http::Method::PUT);
3✔
473
        req->SetHeader("Content-Type", "application/json");
6✔
474
        req->SetHeader("Content-Length", to_string(JsonLogMessagesReader::TotalDataSize(data_size)));
6✔
475
        req->SetHeader("Accept", "application/json");
6✔
476
        req->SetBodyGenerator([logs_reader]() {
15✔
477
                logs_reader->Rewind();
6✔
478
                return logs_reader;
3✔
479
        });
480

481
        auto received_body = make_shared<vector<uint8_t>>();
3✔
482
        return client.AsyncCall(
12✔
483
                req,
484
                [received_body, api_handler](http::ExpectedIncomingResponsePtr exp_resp) {
9✔
485
                        if (!exp_resp) {
3✔
UNCOV
486
                                log::Error("Request to push logs data failed: " + exp_resp.error().message);
×
UNCOV
487
                                api_handler(exp_resp.error());
×
UNCOV
488
                                return;
×
489
                        }
490

491
                        auto body_writer = make_shared<io::ByteWriter>(received_body);
3✔
492
                        auto resp = exp_resp.value();
3✔
493
                        auto content_length = resp->GetHeader("Content-Length");
6✔
494
                        if (!content_length) {
3✔
UNCOV
495
                                log::Debug(
×
496
                                        "Failed to get content length from the status API response headers: "
UNCOV
497
                                        + content_length.error().String());
×
UNCOV
498
                                body_writer->SetUnlimited(true);
×
499
                        } else {
500
                                auto ex_len = common::StringTo<size_t>(content_length.value());
3✔
501
                                if (!ex_len) {
3✔
UNCOV
502
                                        log::Error(
×
503
                                                "Failed to convert the content length from the status API response headers to an integer: "
UNCOV
504
                                                + ex_len.error().String());
×
UNCOV
505
                                        body_writer->SetUnlimited(true);
×
506
                                } else {
507
                                        received_body->resize(ex_len.value());
3✔
508
                                }
509
                        }
510
                        resp->SetBodyWriter(body_writer);
6✔
511
                },
512
                [received_body, api_handler](http::ExpectedIncomingResponsePtr exp_resp) {
9✔
513
                        if (!exp_resp) {
3✔
UNCOV
514
                                log::Error("Request to push logs data failed: " + exp_resp.error().message);
×
UNCOV
515
                                api_handler(exp_resp.error());
×
UNCOV
516
                                return;
×
517
                        }
518

519
                        auto resp = exp_resp.value();
3✔
520
                        auto status = resp->GetStatusCode();
3✔
521
                        if (status == http::StatusNoContent) {
3✔
522
                                api_handler(error::NoError);
4✔
523
                        } else {
524
                                auto ex_err_msg = api::ErrorMsgFromErrorResponse(*received_body);
1✔
525
                                string err_str;
526
                                if (ex_err_msg) {
1✔
527
                                        err_str = ex_err_msg.value();
1✔
528
                                } else {
UNCOV
529
                                        err_str = resp->GetStatusMessage();
×
530
                                }
531
                                api_handler(MakeError(
1✔
532
                                        BadResponseError,
533
                                        "Got unexpected response " + to_string(status) + " from logs API: " + err_str));
2✔
534
                        }
535
                });
3✔
536
}
537

538
} // namespace deployments
539
} // namespace update
540
} // namespace mender
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc