From 699258f830922830df956db8e5dea739ee1642aa Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Wed, 27 May 2026 22:55:39 +0200 Subject: [PATCH] feat: add targeted tracing logs for actor lookup and verification --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/actors.rs | 10 ++++++++++ src/service.rs | 7 ++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40e06e2..cccbb67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1368,7 +1368,7 @@ dependencies = [ [[package]] name = "k-ap" -version = "0.1.5" +version = "0.1.6" dependencies = [ "activitypub_federation", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 6dc608b..45a4c1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "k-ap" -version = "0.1.6" +version = "0.1.7" edition = "2024" description = "Generic ActivityPub protocol layer" license = "MIT" diff --git a/src/actors.rs b/src/actors.rs index f804fc7..4507eee 100644 --- a/src/actors.rs +++ b/src/actors.rs @@ -328,12 +328,22 @@ impl Object for DbActor { return Ok(()); } if apex_domain(json.id.inner()) == apex_domain(expected_domain) { + tracing::debug!( + actor_id = %json.id.inner(), + expected = %expected_domain, + "domain verified via www-apex equivalence" + ); return Ok(()); } verify_domains_match(json.id.inner(), expected_domain).map_err(Error::from) } async fn from_json(json: Self::Kind, data: &Data) -> Result { + tracing::debug!( + actor_id = %json.id.inner(), + username = %json.preferred_username, + "ingesting remote actor" + ); let shared_inbox_url = json.endpoints.as_ref().map(|e| e.shared_inbox.to_string()); let actor = RemoteActor { url: json.id.inner().to_string(), diff --git a/src/service.rs b/src/service.rs index 2cbe11a..eeab58f 100644 --- a/src/service.rs +++ b/src/service.rs @@ -337,10 +337,13 @@ impl ActivityPubService { &self, handle: &str, ) -> anyhow::Result { + tracing::info!(handle, "looking up remote actor"); let data = self.federation_config.to_request_data(); - let actor = Self::webfinger_https(handle, &data).await?; + let actor = Self::webfinger_https(handle, &data).await + .inspect_err(|e| tracing::warn!(handle, error = %e, "actor lookup failed"))?; let domain = actor.ap_id.host_str().unwrap_or("").to_string(); let handle = format!("{}@{}", actor.username, domain); + tracing::info!(handle, ap_url = %actor.ap_id, "remote actor resolved"); Ok(crate::user::LookedUpActor { handle, display_name: actor.display_name, @@ -597,6 +600,7 @@ impl ActivityPubService { "https://{}/.well-known/webfinger?resource=acct:{}@{}", domain_str, user, domain_str ); + tracing::debug!(handle, wf_url, "resolving webfinger"); let wf: serde_json::Value = reqwest::Client::new() .get(&wf_url) .header("Accept", "application/jrd+json, application/json") @@ -615,6 +619,7 @@ impl ActivityPubService { .and_then(|l| l["href"].as_str()) .ok_or_else(|| anyhow::anyhow!("no self link in WebFinger response"))? .to_owned(); + tracing::debug!(handle, self_href, "webfinger resolved, fetching actor with signature"); let self_url = url::Url::parse(&self_href)?; let actor: DbActor = ObjectId::from(self_url) .dereference(data)