#[non_exhaustive]pub enum ConfigValidationError {
EmptyServerName,
EmptyServerVersion,
EmptyToolName(usize),
EmptyTableName(usize),
InlineSecretRejected,
AmbiguousToolKind(usize),
EmptyBackendBaseUrl,
}Expand description
Semantic-validation errors surfaced by
crate::config::ServerConfig::validate.
Per Phase 83 review R8 — the Default impls on ServerConfig and its
sub-sections deliberately allow from_toml to succeed even when required
fields are missing (so partial configs can be merged programmatically). The
crate::config::ServerConfig::validate entry-point catches these gaps at
parse time and surfaces them as a typed enum variant per rule.
The enum is #[non_exhaustive] — match callers must include a wildcard arm
so additional rules can be added without a breaking change.
§Examples
use pmcp_server_toolkit::ConfigValidationError;
// Each variant has a precise `Display` describing the rule violated.
let err = ConfigValidationError::EmptyServerName;
assert_eq!(err.to_string(), "server.name must be non-empty");
let err = ConfigValidationError::EmptyToolName(3);
assert_eq!(err.to_string(), "[[tools]] entry at index 3 has empty name");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EmptyServerName
[server] name is missing or whitespace-only.
EmptyServerVersion
[server] version is missing or whitespace-only.
EmptyToolName(usize)
[[tools]] entry at index has an empty / whitespace-only name.
EmptyTableName(usize)
[[database.tables]] entry at index has an empty / whitespace-only name.
InlineSecretRejected
Per Phase 83 Plan 06 review R9: [code_mode].token_secret was given as
an inline literal (e.g. token_secret = "raw-string") instead of the
env:VAR_NAME reference form, and the dev-only escape hatch
allow_inline_token_secret_for_dev was not set. Inline literals in
committed configs leak HMAC signing keys; the toolkit defaults to
rejecting them.
AmbiguousToolKind(usize)
Per Phase 90 Plan 02 (D-01, T-90-02-04): a [[tools]] entry declares
more than one mutually-exclusive tool kind. A tool is EITHER a SQL tool
(sql), a single-call HTTP tool (path/method), OR a script tool
(script) — never a mixture. The ambiguity is rejected rather than
resolved by a silent precedence rule. The usize is the entry index.
EmptyBackendBaseUrl
Per Phase 90 gap-closure (GAP 3 / WR-02): a [backend] block is present
but its base_url is empty / whitespace-only (or the base_url key was
omitted, defaulting to "" via #[serde(default)]). Without this
parse-time check a typo’d or missing base_url would validate cleanly
and then surface late as an opaque DispatchError::Connector("invalid base URL") at the first backend request. Rejecting it here turns that
late opaque failure into an actionable, field-naming error.
Trait Implementations§
Source§impl Debug for ConfigValidationError
impl Debug for ConfigValidationError
Source§impl Display for ConfigValidationError
impl Display for ConfigValidationError
Source§impl Error for ConfigValidationError
impl Error for ConfigValidationError
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()
Source§impl From<ConfigValidationError> for ToolkitError
impl From<ConfigValidationError> for ToolkitError
Source§fn from(source: ConfigValidationError) -> Self
fn from(source: ConfigValidationError) -> Self
Auto Trait Implementations§
impl Freeze for ConfigValidationError
impl RefUnwindSafe for ConfigValidationError
impl Send for ConfigValidationError
impl Sync for ConfigValidationError
impl Unpin for ConfigValidationError
impl UnsafeUnpin for ConfigValidationError
impl UnwindSafe for ConfigValidationError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more