use std::io::{self, Write};
use std::str::FromStr;
use quick_xml::Writer;
use quick_xml::events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event};
use roxmltree::{Document, Node, ParsingOptions};
use crate::error::{Error, Result, ServiceError};
use crate::model::{
CorrelationId, MessageCode, MessageLevel, ProcessingState, Response, ResponseMetadata,
ServiceMessage, XmlDateTime,
};
use crate::wire::mtom::Attachments;
#[cfg(test)]
use crate::wire::mtom::MimeLimits;
pub(crate) const SOAP_11_NS: &str = "http://schemas.xmlsoap.org/soap/envelope/";
pub(crate) const MESSAGES_NS: &str = "urn:cz:isvs:dmvs:common:schemas:Messages:v1";
pub(crate) const ISDMVS_MESSAGES_NS: &str = "urn:cz:isvs:dmvs:isdmvs:schemas:Messages:v1";
pub(crate) const XSI_NS: &str = "http://www.w3.org/2001/XMLSchema-instance";
/// A central consumer-facing DMVS service with a fixed path and namespace.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub(crate) enum Service {
R18a,
R18b,
R19,
R24a,
R49,
}
impl Service {
pub(crate) const fn path(self) -> &'static str {
match self {
Self::R18a => "R18aCteniVyjadrovateluDti",
Self::R18b => "R18bCteniSubjektu",
Self::R19 => "R19VyhotoveniDatovychSad",
Self::R24a => "R24aCteniCiselniku",
Self::R49 => "R49ZjisteniUzemiSpravcuDti",
}
}
pub(crate) const fn namespace(self) -> &'static str {
match self {
Self::R18a => "urn:cz:isvs:dmvs:isdmvs:schemas:R18aCteniVyjadrovateluDti:v1",
Self::R18b => "urn:cz:isvs:dmvs:isdmvs:schemas:R18bCteniSubjektu:v1",
Self::R19 => "urn:cz:isvs:dmvs:isdmvs:schemas:R19VyhotoveniDatovychSad:v1",
Self::R24a => "urn:cz:isvs:dmvs:isdmvs:schemas:R24aCteniCiselniku:v1",
Self::R49 => "urn:cz:isvs:dmvs:isdmvs:schemas:R49ZjisteniUzemiSpravcuDti:v1",
}
}
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct Operation {
pub(crate) service: Service,
pub(crate) action: &'static str,
pub(crate) request: &'static str,
pub(crate) response: &'static str,
pub(crate) response_data_namespace: &'static str,
}
impl Operation {
pub(crate) const fn new(
service: Service,
action: &'static str,
request: &'static str,
response: &'static str,
) -> Self {
Self {
service,
action,
request,
response,
response_data_namespace: service.namespace(),
}
}
pub(crate) const fn with_response_data_namespace(mut self, namespace: &'static str) -> Self {
self.response_data_namespace = namespace;
self
}
}
#[derive(Clone, Copy)]
pub(crate) struct XmlLimits {
pub(crate) max_nodes: u32,
pub(crate) max_depth: u32,
}
pub(crate) type XmlResult = std::result::Result<(), quick_xml::Error>;
pub(crate) type XmlWriter = Writer<CappedWriter>;
pub(crate) const DEFAULT_MAX_REQUEST_BYTES: usize = 64 * 1024 * 1024;
/// A request buffer that refuses to grow beyond its configured encoded size.
pub(crate) struct CappedWriter {
bytes: Vec<u8>,
limit: usize,
}
impl CappedWriter {
pub(crate) fn new(limit: usize) -> Self {
Self {
bytes: Vec::new(),
limit,
}
}
pub(crate) fn into_inner(self) -> Vec<u8> {
self.bytes
}
}
impl Write for CappedWriter {
fn write(&mut self, buffer: &[u8]) -> io::Result<usize> {
let new_len = self
.bytes
.len()
.checked_add(buffer.len())
.filter(|length| *length <= self.limit)
.ok_or_else(|| {
io::Error::new(
io::ErrorKind::FileTooLarge,
"encoded request exceeds its configured byte limit",
)
})?;
if new_len > self.bytes.capacity() {
let grown = self.bytes.capacity().max(1).saturating_mul(2);
let capacity = grown.max(new_len).min(self.limit);
let additional = capacity.saturating_sub(self.bytes.len());
self.bytes.try_reserve_exact(additional).map_err(|_| {
io::Error::new(
io::ErrorKind::OutOfMemory,
"could not allocate the encoded request buffer",
)
})?;
}
self.bytes.extend_from_slice(buffer);
debug_assert_eq!(self.bytes.len(), new_len);
Ok(buffer.len())
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
#[cfg(test)]
pub(crate) fn request(
operation: Operation,
correlation_id: CorrelationId,
write_contents: impl FnOnce(&mut XmlWriter) -> XmlResult,
) -> Result<Vec<u8>> {
request_with_limit(
operation,
correlation_id,
DEFAULT_MAX_REQUEST_BYTES,
write_contents,
)
}
pub(crate) fn request_with_limit(
operation: Operation,
correlation_id: CorrelationId,
max_request_bytes: usize,
write_contents: impl FnOnce(&mut XmlWriter) -> XmlResult,
) -> Result<Vec<u8>> {
let mut writer = XmlWriter::new(CappedWriter::new(max_request_bytes));
write_envelope(&mut writer, operation, correlation_id, write_contents)
.map_err(|error| map_request_error(error, max_request_bytes))?;
Ok(writer.into_inner().into_inner())
}
pub(crate) fn request_too_large(limit: usize) -> Error {
Error::invalid_input(
"max_request_bytes",
format!("encoded request exceeds the configured {limit}-byte limit"),
)
}
fn map_request_error(error: quick_xml::Error, limit: usize) -> Error {
if matches!(
&error,
quick_xml::Error::Io(source) if source.kind() == io::ErrorKind::FileTooLarge
) {
return request_too_large(limit);
}
Error::invalid_input("xml", format!("could not encode request: {error}"))
}
fn write_envelope(
writer: &mut XmlWriter,
operation: Operation,
correlation_id: CorrelationId,
write_contents: impl FnOnce(&mut XmlWriter) -> XmlResult,
) -> XmlResult {
writer.write_event(Event::Decl(BytesDecl::new("1.0", Some("UTF-8"), None)))?;
let mut envelope = BytesStart::new("soap:Envelope");
envelope.push_attribute(("xmlns:soap", SOAP_11_NS));
envelope.push_attribute(("xmlns:xsi", XSI_NS));
writer.write_event(Event::Start(envelope))?;
writer.write_event(Event::Empty(BytesStart::new("soap:Header")))?;
writer.write_event(Event::Start(BytesStart::new("soap:Body")))?;
let mut request = BytesStart::new(operation.request);
request.push_attribute(("xmlns", operation.service.namespace()));
request.push_attribute(("xmlns:m", MESSAGES_NS));
writer.write_event(Event::Start(request))?;
element(writer, "m:Hlavicka", |writer| {
text_element(
writer,
"m:UidZadosti",
&correlation_id.as_uuid().to_string(),
)
})?;
write_contents(writer)?;
writer.write_event(Event::End(BytesEnd::new(operation.request)))?;
writer.write_event(Event::End(BytesEnd::new("soap:Body")))?;
writer.write_event(Event::End(BytesEnd::new("soap:Envelope")))?;
Ok(())
}
pub(crate) fn text_element(writer: &mut XmlWriter, name: &str, value: &str) -> XmlResult {
writer.write_event(Event::Start(BytesStart::new(name)))?;
writer.write_event(Event::Text(BytesText::new(value)))?;
writer.write_event(Event::End(BytesEnd::new(name)))?;
Ok(())
}
pub(crate) fn empty_element(writer: &mut XmlWriter, name: &str) -> XmlResult {
writer.write_event(Event::Empty(BytesStart::new(name)))?;
Ok(())
}
pub(crate) fn element(
writer: &mut XmlWriter,
name: &str,
write_contents: impl FnOnce(&mut XmlWriter) -> XmlResult,
) -> XmlResult {
writer.write_event(Event::Start(BytesStart::new(name)))?;
write_contents(writer)?;
writer.write_event(Event::End(BytesEnd::new(name)))?;
Ok(())
}
pub(crate) fn parse<T: FromStr>(value: &str, name: &str) -> Result<T> {
value
.trim()
.parse()
.map_err(|_| Error::invalid_response(format!("{name} has an invalid value")))
}
pub(crate) fn parse_bool(value: &str, name: &str) -> Result<bool> {
match value.trim() {
"true" | "1" => Ok(true),
"false" | "0" => Ok(false),
_ => Err(Error::invalid_response(format!(
"{name} is not an XML boolean"
))),
}
}
pub(crate) fn xml_bool(value: bool) -> &'static str {
if value { "true" } else { "false" }
}
pub(crate) fn parse_date_time(value: String) -> Result<XmlDateTime> {
XmlDateTime::new(value).map_err(|_| Error::invalid_response("invalid XML date-time"))
}
#[cfg(test)]
pub(crate) fn decode<T>(
bytes: &[u8],
operation: Operation,
correlation_id: CorrelationId,
limits: XmlLimits,
decode_data: impl FnOnce(Option<Node<'_, '_>>) -> Result<T>,
) -> Result<Response<T>> {
let attachments = Attachments::inline(MimeLimits {
max_parts: 1,
max_decoded_bytes: bytes.len(),
max_total_decoded_bytes: bytes.len(),
});
decode_with_attachments(
bytes,
&attachments,
operation,
correlation_id,
limits,
|data, _| decode_data(data),
)
}
pub(crate) fn decode_with_attachments<T>(
bytes: &[u8],
attachments: &Attachments<'_>,
operation: Operation,
correlation_id: CorrelationId,
limits: XmlLimits,
decode_data: impl FnOnce(Option<Node<'_, '_>>, &Attachments<'_>) -> Result<T>,
) -> Result<Response<T>> {
let xml = std::str::from_utf8(bytes)
.map_err(|_| Error::invalid_response("response is not UTF-8 XML"))?;
preflight(xml, limits)?;
let options = ParsingOptions {
allow_dtd: false,
nodes_limit: limits.max_nodes,
..ParsingOptions::default()
};
let document = Document::parse_with_options(xml, options)
.map_err(|_| Error::invalid_response("malformed XML response"))?;
let envelope = document.root_element();
require_tag(envelope, SOAP_11_NS, "Envelope")?;
let body = child(envelope, SOAP_11_NS, "Body")?
.ok_or_else(|| Error::invalid_response("SOAP Body is missing"))?;
let body_elements: Vec<_> = body.children().filter(|node| node.is_element()).collect();
if body_elements.len() != 1 {
return Err(Error::invalid_response(
"SOAP Body must contain exactly one element",
));
}
let root = body_elements[0];
if root.tag_name().namespace() == Some(SOAP_11_NS) && root.tag_name().name() == "Fault" {
let code = descendant_text(root, "faultcode")?.unwrap_or_else(|| "unknown".to_owned());
let message = descendant_text(root, "faultstring")?
.unwrap_or_else(|| "unspecified SOAP fault".to_owned());
return Err(Error::SoapFault { code, message });
}
require_tag(root, operation.service.namespace(), operation.response)?;
let header = child(root, MESSAGES_NS, "Hlavicka")?
.ok_or_else(|| Error::invalid_response("response header is missing"))?;
let response_id = required_text(header, MESSAGES_NS, "UidOdpovedi")?
.parse::<CorrelationId>()
.map_err(|_| Error::invalid_response("response UUID is invalid"))?;
let result = child(header, MESSAGES_NS, "Vysledek")?
.ok_or_else(|| Error::invalid_response("response result is missing"))?;
let state = result
.attribute("stav")
.map(ProcessingState::from_raw)
.ok_or_else(|| Error::invalid_response("response processing state is missing"))?;
let request_id = required_text(result, MESSAGES_NS, "UidZadosti")?
.parse::<CorrelationId>()
.map_err(|_| Error::invalid_response("request UUID is invalid"))?;
if request_id != correlation_id {
return Err(Error::invalid_response(
"response request UUID does not match",
));
}
let messages = decode_messages(result)?;
let metadata = ResponseMetadata {
response_id,
request_id,
state,
messages,
};
if metadata.state == ProcessingState::Failed {
return Err(ServiceError::new(metadata.messages).into());
}
let data = child(root, operation.response_data_namespace, "Data")?;
let response = Response {
value: decode_data(data, attachments)?,
metadata,
};
attachments.finish()?;
Ok(response)
}
fn decode_messages(result: Node<'_, '_>) -> Result<Vec<ServiceMessage>> {
let wrapper = child(result, MESSAGES_NS, "Hlaseni")?
.ok_or_else(|| Error::invalid_response("response message wrapper is missing"))?;
children(wrapper, MESSAGES_NS, "Hlaseni")
.map(|message| {
let code = message
.attribute("kod")
.map(MessageCode::from_raw)
.ok_or_else(|| Error::invalid_response("message code is missing"))?;
let level = message
.attribute("typ")
.map(MessageLevel::from_raw)
.ok_or_else(|| Error::invalid_response("message severity is missing"))?;
Ok(ServiceMessage {
code,
level,
text: required_text_or_empty(message, MESSAGES_NS, "Zprava")?,
detail: optional_text(message, MESSAGES_NS, "Detail")?,
})
})
.collect()
}
fn preflight(xml: &str, limits: XmlLimits) -> Result<()> {
let mut reader = quick_xml::Reader::from_str(xml);
let mut nodes = 0_u32;
let mut depth = 0_u32;
loop {
match reader.read_event() {
Ok(Event::Eof) => break,
Ok(Event::Start(element)) => {
nodes = preflight_node(nodes, limits.max_nodes)?;
nodes = preflight_attributes(&element, nodes, limits.max_nodes)?;
depth = depth.checked_add(1).ok_or_else(|| {
Error::invalid_response("XML response exceeds the nesting limit")
})?;
if depth > limits.max_depth {
return Err(Error::invalid_response(
"XML response exceeds the nesting limit",
));
}
}
Ok(Event::Empty(element)) => {
if depth >= limits.max_depth {
return Err(Error::invalid_response(
"XML response exceeds the nesting limit",
));
}
nodes = preflight_node(nodes, limits.max_nodes)?;
nodes = preflight_attributes(&element, nodes, limits.max_nodes)?;
}
Ok(Event::End(_)) => {
depth = depth
.checked_sub(1)
.ok_or_else(|| Error::invalid_response("malformed XML response"))?;
}
Ok(Event::DocType(_)) => {
return Err(Error::invalid_response(
"DTD is not allowed in XML responses",
));
}
Ok(
Event::Text(_)
| Event::CData(_)
| Event::Comment(_)
| Event::Decl(_)
| Event::PI(_)
| Event::GeneralRef(_),
) => nodes = preflight_node(nodes, limits.max_nodes)?,
Err(_) => return Err(Error::invalid_response("malformed XML response")),
}
}
if depth != 0 {
return Err(Error::invalid_response("malformed XML response"));
}
Ok(())
}
fn preflight_node(nodes: u32, limit: u32) -> Result<u32> {
let nodes = nodes
.checked_add(1)
.ok_or_else(|| Error::invalid_response("XML response exceeds the node limit"))?;
if nodes > limit {
return Err(Error::invalid_response(
"XML response exceeds the node limit",
));
}
Ok(nodes)
}
fn preflight_attributes(element: &BytesStart<'_>, mut nodes: u32, limit: u32) -> Result<u32> {
for attribute in element.attributes() {
if attribute.is_err() {
return Err(Error::invalid_response("malformed XML response"));
}
nodes = preflight_node(nodes, limit)?;
}
Ok(nodes)
}
pub(crate) fn require_tag(node: Node<'_, '_>, namespace: &str, name: &str) -> Result<()> {
if node.tag_name().namespace() == Some(namespace) && node.tag_name().name() == name {
Ok(())
} else {
Err(Error::invalid_response(format!(
"expected XML element {name}"
)))
}
}
pub(crate) fn child<'a, 'input>(
node: Node<'a, 'input>,
namespace: &str,
name: &str,
) -> Result<Option<Node<'a, 'input>>> {
child_namespaces(node, &[namespace], name)
}
pub(crate) fn child_namespaces<'a, 'input>(
node: Node<'a, 'input>,
namespaces: &[&str],
name: &str,
) -> Result<Option<Node<'a, 'input>>> {
let mut matches = node.children().filter(|candidate| {
candidate.is_element()
&& candidate.tag_name().name() == name
&& candidate
.tag_name()
.namespace()
.is_some_and(|namespace| namespaces.contains(&namespace))
});
let first = matches.next();
if matches.next().is_some() {
return Err(Error::invalid_response(format!(
"XML element {name} occurs more than once"
)));
}
Ok(first)
}
pub(crate) fn children<'a, 'input>(
node: Node<'a, 'input>,
namespace: &str,
name: &str,
) -> impl Iterator<Item = Node<'a, 'input>> {
node.children().filter(move |candidate| {
candidate.is_element()
&& candidate.tag_name().namespace() == Some(namespace)
&& candidate.tag_name().name() == name
})
}
pub(crate) fn is_nil(node: Node<'_, '_>) -> bool {
node.attribute((XSI_NS, "nil"))
.is_some_and(|value| value == "true" || value == "1")
}
pub(crate) fn optional_text(
node: Node<'_, '_>,
namespace: &str,
name: &str,
) -> Result<Option<String>> {
optional_text_namespaces(node, &[namespace], name)
}
pub(crate) fn optional_text_namespaces(
node: Node<'_, '_>,
namespaces: &[&str],
name: &str,
) -> Result<Option<String>> {
let Some(element) = child_namespaces(node, namespaces, name)? else {
return Ok(None);
};
let content = simple_content(element, name)?;
if is_nil(element) {
if !content.is_empty() {
return Err(Error::invalid_response(format!(
"nil XML element {name} contains text"
)));
}
return Ok(None);
}
Ok(Some(content))
}
pub(crate) fn required_text(node: Node<'_, '_>, namespace: &str, name: &str) -> Result<String> {
required_text_namespaces(node, &[namespace], name)
}
pub(crate) fn required_text_namespaces(
node: Node<'_, '_>,
namespaces: &[&str],
name: &str,
) -> Result<String> {
optional_text_namespaces(node, namespaces, name)?
.filter(|text| !text.is_empty())
.ok_or_else(|| Error::invalid_response(format!("required XML element {name} is missing")))
}
pub(crate) fn required_text_or_empty(
node: Node<'_, '_>,
namespace: &str,
name: &str,
) -> Result<String> {
let element = child(node, namespace, name)?.ok_or_else(|| {
Error::invalid_response(format!("required XML element {name} is missing"))
})?;
if is_nil(element) {
return Err(Error::invalid_response(format!(
"required XML element {name} is nil"
)));
}
simple_content(element, name)
}
pub(crate) fn simple_content(node: Node<'_, '_>, name: &str) -> Result<String> {
let mut content = String::new();
for child in node.children() {
if child.is_element() {
return Err(Error::invalid_response(format!(
"XML element {name} contains a nested element"
)));
}
if child.is_text()
&& let Some(text) = child.text()
{
content.push_str(text);
}
}
Ok(content)
}
fn descendant_text(node: Node<'_, '_>, name: &str) -> Result<Option<String>> {
let mut matches = node
.descendants()
.filter(|candidate| candidate.is_element() && candidate.tag_name().name() == name);
let first = matches.next();
if matches.next().is_some() {
return Err(Error::invalid_response(format!(
"SOAP fault element {name} occurs more than once"
)));
}
first.map(|node| simple_content(node, name)).transpose()
}
#[cfg(test)]
mod tests {
use super::*;
const OPERATION: Operation = Operation::new(
Service::R24a,
"vylistujVerzeJvf",
"VylistujVerzeJvf",
"VylistujVerzeJvfOdpoved",
);
const UUID: &str = "ed8af7af-5b39-4dff-96ab-7561214336f1";
fn limits() -> XmlLimits {
XmlLimits {
max_nodes: 65_536,
max_depth: 128,
}
}
#[test]
fn writes_soap_11_request_without_business_data() {
let id = UUID.parse().unwrap();
let xml = request(OPERATION, id, |_| Ok(())).unwrap();
let xml = std::str::from_utf8(&xml).unwrap();
assert!(xml.contains("xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""));
assert!(xml.contains("xmlns=\"urn:cz:isvs:dmvs:isdmvs:schemas:R24aCteniCiselniku:v1\""));
assert!(xml.contains("<m:UidZadosti>ed8af7af-5b39-4dff-96ab-7561214336f1</m:UidZadosti>"));
assert!(!xml.contains("<Data>"));
}
#[test]
fn request_byte_limit_is_exact_and_rejects_oversized_text() {
let text = "synthetic text".repeat(512);
let write = |writer: &mut XmlWriter| text_element(writer, "m:Text", &text);
let encoded = request(OPERATION, UUID.parse().unwrap(), write).unwrap();
let exact = request_with_limit(OPERATION, UUID.parse().unwrap(), encoded.len(), |writer| {
text_element(writer, "m:Text", &text)
})
.unwrap();
assert_eq!(exact, encoded);
let error = request_with_limit(
OPERATION,
UUID.parse().unwrap(),
encoded.len() - 1,
|writer| text_element(writer, "m:Text", &text),
)
.unwrap_err();
assert!(matches!(
error,
Error::InvalidInput {
field: "max_request_bytes",
..
}
));
}
#[test]
fn capped_writer_does_not_append_a_write_that_crosses_the_limit() {
let mut writer = CappedWriter::new(8);
writer.write_all(b"12345678").unwrap();
let error = writer.write(b"9").unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::FileTooLarge);
assert_eq!(writer.into_inner(), b"12345678");
}
fn response(state: &str, code: &str, level: &str) -> Vec<u8> {
format!(
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"{SOAP_11_NS}\"><SOAP-ENV:Body><ns5:VylistujVerzeJvfOdpoved xmlns:ns5=\"{}\" xmlns:ns3=\"{MESSAGES_NS}\"><ns3:Hlavicka><ns3:UidOdpovedi>c5f073e9-d3e9-4845-aae0-de3ef42357be</ns3:UidOdpovedi><ns3:Vysledek stav=\"{state}\"><ns3:UidZadosti>{UUID}</ns3:UidZadosti><ns3:Hlaseni><ns3:Hlaseni kod=\"{code}\" typ=\"{level}\"><ns3:Zprava>server text</ns3:Zprava><ns3:Detail>detail</ns3:Detail></ns3:Hlaseni></ns3:Hlaseni></ns3:Vysledek></ns3:Hlavicka><ns5:Data/></ns5:VylistujVerzeJvfOdpoved></SOAP-ENV:Body></SOAP-ENV:Envelope>",
Service::R24a.namespace()
)
.into_bytes()
}
#[test]
fn decodes_common_metadata_and_preserves_unknown_values() {
let response = decode(
&response("OK", "future-code", "FutureLevel"),
OPERATION,
UUID.parse().unwrap(),
limits(),
|_| Ok(()),
)
.unwrap();
assert_eq!(response.metadata.state, ProcessingState::Ok);
assert_eq!(
response.metadata.messages[0].code,
MessageCode::Other("future-code".into())
);
assert_eq!(
response.metadata.messages[0].level,
MessageLevel::Other("FutureLevel".into())
);
assert_eq!(response.metadata.messages[0].text, "server text");
}
#[test]
fn service_failure_does_not_need_data() {
let error = decode(
&response("Chyba", "3200", "Chyba"),
OPERATION,
UUID.parse().unwrap(),
limits(),
|_| Ok(()),
)
.unwrap_err();
assert!(error.is_authentication_failure());
}
#[test]
fn rejects_correlation_mismatch_dtd_and_fault_without_leaking_body() {
let error = decode(
&response("OK", "1000", "Informace"),
OPERATION,
CorrelationId::new(),
limits(),
|_| Ok(()),
)
.unwrap_err();
assert!(matches!(error, Error::InvalidResponse { .. }));
let dtd = b"<!DOCTYPE foo [<!ENTITY xxe SYSTEM 'file:///secret'>]><foo/>";
assert!(decode(dtd, OPERATION, UUID.parse().unwrap(), limits(), |_| Ok(())).is_err());
let fault = format!(
"<soap:Envelope xmlns:soap=\"{SOAP_11_NS}\"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>sensitive fault</faultstring></soap:Fault></soap:Body></soap:Envelope>"
);
let error = decode(
fault.as_bytes(),
OPERATION,
UUID.parse().unwrap(),
limits(),
|_| Ok(()),
)
.unwrap_err();
assert!(!format!("{error}").contains("sensitive"));
assert!(!format!("{error:?}").contains("sensitive"));
}
}