From 12b0fb7f91e8483e9a018d1e3b8b8d6f6659328c Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Sun, 23 Jun 2024 16:16:59 -0700 Subject: [PATCH] don't write KBs of html to the logs Handing this to tracing as a String makes it automatically escape newlines and such. --- src/api/server_server.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/api/server_server.rs b/src/api/server_server.rs index cd0386b8..f1fdd412 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -69,7 +69,9 @@ use crate::{ api::client_server::{self, claim_keys_helper, get_keys_helper}, observability::{FoundIn, Lookup, METRICS}, service::pdu::{gen_event_id_canonical_json, PduBuilder}, - services, utils, Ar, Error, PduEvent, Ra, Result, + services, utils, + utils::dbg_truncate_str, + Ar, Error, PduEvent, Ra, Result, }; /// Wraps either an literal IP address plus port, or a hostname plus complement @@ -281,10 +283,11 @@ where if status != 200 { warn!( status = u16::from(status), - response = String::from_utf8_lossy(&body) - .lines() - .collect::>() - .join(" "), + response = dbg_truncate_str( + String::from_utf8_lossy(&body).as_ref(), + 100, + ) + .into_owned(), "Received error over federation", ); }