Keep network details and URLs out of podcast fetch errors

Users see the kind of failure only; resolved addresses and transport
details go to the logs, without URLs. Feed and audio requests are
limited to the web ports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-20 15:12:38 +02:00
1 parent 99b2935b35
commit c51a9af9e5
10 files changed
+256 -42

No files matched your search

+26 -2
View File
@@ -81,6 +81,9 @@ impl From<anyhow::Error> for ApiError {
FetchErrorKind::Timeout | FetchErrorKind::Transport => 502,
_ => 422,
};
// The user sees the kind of failure only (no resolved
// addresses or transport details); the log keeps the details.
tracing::info!("podcast feed could not be added: {}", fetch.message);
return Self::new(status, error.to_string());
}
tracing::warn!("podcast API request failed: {error:#}");
@@ -975,12 +978,21 @@ mod tests {
let refused: ApiError =
anyhow::Error::from(SubscribeUrlError::Fetch(super::super::fetch::FetchError {
kind: FetchErrorKind::Refused,
message: "address 127.0.0.1 is not public".into(),
message: "intranet.corp resolves to a private address (10.1.2.3)".into(),
retry_after: None,
}))
.into();
assert_eq!(refused.status, 422);
assert!(refused.message.contains("not public"));
assert!(
refused.message.contains("only public"),
"{}",
refused.message
);
assert!(
!refused.message.contains("10.1.2.3"),
"no resolved addresses"
);
assert!(!refused.message.contains("intranet"));
let timeout: ApiError =
anyhow::Error::from(SubscribeUrlError::Fetch(super::super::fetch::FetchError {
kind: FetchErrorKind::Timeout,
@@ -989,6 +1001,18 @@ mod tests {
}))
.into();
assert_eq!(timeout.status, 502);
let transport: ApiError =
anyhow::Error::from(SubscribeUrlError::Fetch(super::super::fetch::FetchError {
kind: FetchErrorKind::Transport,
message: "error sending request: tcp connect error: Connection refused".into(),
retry_after: None,
}))
.into();
assert_eq!(transport.status, 502);
assert_eq!(
transport.message,
"the feed could not be loaded: could not connect to the server"
);
let other: ApiError = anyhow::anyhow!("connection reset").into();
assert_eq!(other.status, 500);
assert_eq!(other.message, "internal error", "internals are not shown");