Skip to content

Commit

Permalink
fix: add guard clause
Browse files Browse the repository at this point in the history
  • Loading branch information
pranc1ngpegasus committed Oct 19, 2024
1 parent 4fb86fd commit 1952571
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions agent/src/services/studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ impl MetricStoreRepository for Studio {

while let Some(m) = metrics.pop_front() {
let item_size = serde_json::to_string(&m)?.len();
if item_size > JSON_BODY_MAX_SIZE {
anyhow::bail!("invalid item size: JSON body size too large")
}
if current_size + item_size > JSON_BODY_MAX_SIZE {
metrics.push_front(m);
break;
Expand Down

0 comments on commit 1952571

Please sign in to comment.