Skip to content

Commit

Permalink
liteclient: Append notice if event context is truncated
Browse files Browse the repository at this point in the history
If an update event description is truncated because it exceeds the
maximum allowed size then append `TRUNCATED` to its end so a user is
aware that the event description is truncated.

Signed-off-by: Mike Sul <[email protected]>
  • Loading branch information
mike-sul committed Aug 28, 2024
1 parent f3edf41 commit 22cbd64
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/liteclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ void LiteClient::notify(const Uptane::Target& t, std::unique_ptr<ReportEvent> ev
if (event->custom.isMember("details")) {
const auto detail_str{event->custom["details"].asString()};
if (detail_str.size() > MaxDetailsSize) {
event->custom["details"] = detail_str.substr(0, MaxDetailsSize);
static const std::string truncated{"[TRUNCATED]"};
event->custom["details"] = detail_str.substr(0, MaxDetailsSize - truncated.size()) + truncated;
}
}
report_queue->enqueue(std::move(event));
Expand Down

0 comments on commit 22cbd64

Please sign in to comment.