fix: reduce log noise for expected state event rejections during sync

State events from remote relays for repos we don't host are expected
rejections during proactive sync. Changed to only WARN for user-submitted
events (potential misconfiguration/attack) while using DEBUG for synced
events (normal operation).

This reduces log noise from ~1967 warnings to <10 warnings in a 30-second
production sync test, making real issues visible again.
This commit is contained in:
DanConwayDev
2026-01-10 00:29:46 +00:00
parent ced6ef15a1
commit a84ae9f2a2
+32 -13
View File
@@ -81,12 +81,21 @@ impl StatePolicy {
// CRITICAL: Check if author is authorized via maintainer set
// State events MUST be rejected if author is not in maintainer set of any accepted announcement
if db_repo_data.announcements.is_empty() {
tracing::warn!(
event_id = %event.id,
identifier = %state.identifier,
author = %event.pubkey.to_hex(),
"Rejecting state event: no announcement exists for this repository"
);
if is_synced {
tracing::debug!(
event_id = %event.id,
identifier = %state.identifier,
author = %event.pubkey.to_hex(),
"Rejecting state event: no announcement exists for this repository"
);
} else {
tracing::warn!(
event_id = %event.id,
identifier = %state.identifier,
author = %event.pubkey.to_hex(),
"Rejecting state event: no announcement exists for this repository"
);
}
return Ok(WritePolicyResult::Reject {
status: false,
message: "invalid: no announcement exists for this repository".into(),
@@ -99,13 +108,23 @@ impl StatePolicy {
);
if authorized_owners.is_empty() {
tracing::warn!(
event_id = %event.id,
identifier = %state.identifier,
author = %event.pubkey.to_hex(),
announcements_count = db_repo_data.announcements.len(),
"Rejecting state event: author not in maintainer set of any announcement"
);
if is_synced {
tracing::debug!(
event_id = %event.id,
identifier = %state.identifier,
author = %event.pubkey.to_hex(),
announcements_count = db_repo_data.announcements.len(),
"Rejecting state event: author not in maintainer set of any announcement"
);
} else {
tracing::warn!(
event_id = %event.id,
identifier = %state.identifier,
author = %event.pubkey.to_hex(),
announcements_count = db_repo_data.announcements.len(),
"Rejecting state event: author not in maintainer set of any announcement"
);
}
return Ok(WritePolicyResult::Reject {
status: false,
message: "invalid: author not authorized for this repository".into(),