MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / is_valid_bedrock_model_id

Function is_valid_bedrock_model_id

crates/openshell-router/src/backend.rs:926–943  ·  view source on GitHub ↗

Defense-in-depth predicate matching the server-side `validate_aws_bedrock_model_id` contract — see that function for the authoritative reasoning. Returns `true` when `value` is safe to interpolate into a Bedrock URL path segment. The router uses this before constructing an upstream path so a stale or out-of-band route store cannot bypass the resolver's validation.

(value: &str)

Source from the content-addressed store, hash-verified

924/// before constructing an upstream path so a stale or out-of-band route
925/// store cannot bypass the resolver's validation.
926fn is_valid_bedrock_model_id(value: &str) -> bool {
927 if value.is_empty() || value != value.trim() {
928 return false;
929 }
930 if value.contains('/') || value.contains('\\') {
931 return false;
932 }
933 if value.chars().any(|c| matches!(c, '?' | '#' | '%')) {
934 return false;
935 }
936 if value.contains("..") {
937 return false;
938 }
939 if value.chars().any(|c| c.is_control() || c.is_whitespace()) {
940 return false;
941 }
942 true
943}
944
945/// Check whether a route targets a Vertex AI Anthropic rawPredict endpoint.
946///

Callers 1

rewrite_bedrock_pathFunction · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected