Skip to main content

systemprompt_identifiers/
provider_request.rs

1//! Opaque request identifier echoed by upstream model providers.
2//!
3//! Captured for observability when a provider returns a trace token in
4//! its response (e.g. via `x-context-id` or analogous headers). The shape
5//! is provider-defined, so this id is only validated for non-empty and a
6//! sane upper length bound.
7
8use crate::error::IdValidationError;
9
10const MAX_LEN: usize = 256;
11
12fn validate(value: &str) -> Result<(), IdValidationError> {
13    if value.is_empty() {
14        return Err(IdValidationError::empty("ProviderRequestId"));
15    }
16    if value.len() > MAX_LEN {
17        return Err(IdValidationError::invalid(
18            "ProviderRequestId",
19            "exceeds maximum length",
20        ));
21    }
22    Ok(())
23}
24
25crate::define_id!(ProviderRequestId, validated, schema, validate);