Skip to main content

require_non_blank

Function require_non_blank 

Source
pub fn require_non_blank(member: &str, value: &str) -> Result<(), Error>
Expand description

Rejects a NonBlankString value the service would reject.

§The model’s most-reused shape, and the three members this client sends

NonBlankString is min: 1, max: 2048, pattern: [^\s]+ and 45 members name it. Most are responses; the three this client puts on the wire are CodeArtifact.uri, CreateMicrovmImage.baseImageArn, and ListMicrovmImages.nameFilter, and issue #24 named all three as reachable with no guard.

Each of the three fails in its own expensive way. codeArtifact.uri and baseImageArn ride on the create call, which happens after the artifact upload — the ordering ControlPlane::create_image is arranged around, so a rejection about either costs the caller the upload. nameFilter is worse in a quieter way: it goes in the query string, so a blank one is a nameFilter= that either 400s or silently filters differently from what was meant, and ControlPlane::find_image_by_name is the resolver a launch depends on.

§[^\s]+ forbids whitespace anywhere

Not merely “not blank”. An S3 URI pasted from a console with a trailing newline satisfies “non-empty” and fails the pattern, which is why the message names the character it found rather than saying the value is invalid. The same reading require_valid_version documents for Version, which is the identical constraint triple on a different shape.

A separate function from require_valid_version even though the two shapes agree today, for the reason crate::constants::MAX_NON_BLANK_LEN gives: they are two shapes, AWS can move one, and one guard serving both would silently stop being about whichever moved.