pub enum ServerIdError {
InvalidFormat {
id: String,
},
DisallowedCharacter {
id: String,
code_point: u32,
},
}Expand description
Error returned when a candidate string fails the invariant ServerId::new enforces.
Every variant’s #[error(...)] message formats its stored string field with {:?}
(Debug), not {} (Display) — this is a required second layer of defense, not
incidental formatting, and must not be “simplified” to {}. sanitize_untrusted_inline
only neutralizes &/</> plus the control/bidi-reordering characters
sanitize_untrusted_text targets; it deliberately leaves other characters untouched (e.g.
U+200C/U+200D, orthographically load-bearing in some scripts and emoji ZWJ sequences — see
that function’s doc comment), so the stored field can still carry a raw invisible or
format character. Debug’s own escaping (\u{200d} rather than the literal character) is
what keeps that residual case from smuggling an invisible payload into LLM-facing or
terminal-rendered error text (issues #425/#430); switching to Display would silently
reopen that channel for every field this crate stores unsanitized-but-quoted this way.
§Examples
use mcp_execution_core::{ServerId, ServerIdError};
let err = ServerId::new("../etc").unwrap_err();
assert!(matches!(err, ServerIdError::InvalidFormat { .. }));Variants§
InvalidFormat
id is not a single non-empty path segment: it is empty, or contains a .., a path
separator, or a root/prefix component.
Fields
id: StringSanitized form of the rejected input (see
sanitize_untrusted_inline):
control characters, bidi-reordering characters, and other invisible/structural
characters are neutralized, and &/</> are entity-escaped, since this value is
attacker-controlled and reaches LLM-facing error text.
DisallowedCharacter
id is a well-formed path segment but contains a character that is not UTS #39
Identifier_Status=Allowed (see crate::first_disallowed_identifier_char).
Fields
id: StringSanitized form of the rejected input (see
sanitize_untrusted_inline):
control characters, bidi-reordering characters, and other invisible/structural
characters are neutralized, and &/</> are entity-escaped, since this value is
attacker-controlled and reaches LLM-facing error text.
Trait Implementations§
Source§impl Clone for ServerIdError
impl Clone for ServerIdError
Source§fn clone(&self) -> ServerIdError
fn clone(&self) -> ServerIdError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServerIdError
impl Debug for ServerIdError
Source§impl Display for ServerIdError
impl Display for ServerIdError
impl Eq for ServerIdError
Source§impl Error for ServerIdError
impl Error for ServerIdError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()