taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit b6a0246708cf9b9f39e3ff8d4d01cec4b44c19bf
parent 3af1bc9fd3fd76faea4c67351b8736e58097c267
Author: Antoine A <>
Date:   Tue, 24 Nov 2026 16:12:20 +0100

api: value of a refused path segment hidden from the log

Diffstat:
Mcommon/taler-api/src/error.rs | 28+++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/common/taler-api/src/error.rs b/common/taler-api/src/error.rs @@ -201,6 +201,31 @@ fn json_error_kind(error: &serde_json::Error) -> &'static str { } } +/// Describe a path deserialization error for logging without quoting the input. +fn path_error_kind(error: &ErrorKind) -> String { + match error { + ErrorKind::ParseError { expected_type, .. } => format!("expected {expected_type}"), + ErrorKind::ParseErrorAtIndex { + index, + expected_type, + .. + } => format!("{index}: expected {expected_type}"), + ErrorKind::ParseErrorAtKey { + key, expected_type, .. + } => format!("{key}: expected {expected_type}"), + ErrorKind::InvalidUtf8InPathParam { key } => format!("{key}: invalid UTF-8"), + ErrorKind::DeserializeError { key, message, .. } => { + format!("{key}: {}", serde_error_kind(message)) + } + ErrorKind::Message(message) => serde_error_kind(message).into(), + ErrorKind::WrongNumberOfParameters { got, expected } => { + format!("expected {expected} path parameters, got {got}") + } + ErrorKind::UnsupportedType { name } => format!("unsupported type {name}"), + _ => "invalid data".into(), + } +} + fn deserialization_failure( code: ErrorCode, hint: impl Display, @@ -248,7 +273,8 @@ impl From<PathRejection> for ApiError { match value { PathRejection::FailedToDeserializePathParams(err) => { let kind = err.into_kind(); - let err = failure(ErrorCode::GENERIC_PATH_SEGMENT_MALFORMED, &kind); + let err = failure(ErrorCode::GENERIC_PATH_SEGMENT_MALFORMED, &kind) + .with_log(path_error_kind(&kind)); match kind { ErrorKind::ParseErrorAtKey { key, .. } | ErrorKind::InvalidUtf8InPathParam { key }