pub enum PackageError {
Serialize(Error),
Io(Error),
DigestMismatch {
expected: String,
actual: String,
},
MalformedDigest {
reason: String,
},
AllowlistViolation {
resource: String,
},
InvalidReference {
reason: String,
},
SlotConflict {
slot: String,
tested: String,
proposed: String,
},
Layout {
reason: String,
},
ConfigSlotViolation {
key: String,
reason: String,
},
AttestationSubjectMismatch {
supplied: String,
computed: String,
},
AttestationAnnotationInvalid {
annotation: String,
reason: String,
},
}Expand description
All ways a pmcp-package operation can fail.
Variants§
Serialize(Error)
JSON (de)serialization failure. Covers both directions — serde_json
has a single Error type for both, so there is exactly one variant.
Io(Error)
Filesystem I/O failure (OCI layout read/write, blob read/write).
DigestMismatch
A recomputed digest did not match the digest declared in a manifest or descriptor (tamper detection).
MalformedDigest
A digest string is not well-formed (e.g. not sha256:<64-hex>).
AllowlistViolation
A deploy descriptor requested a CloudFormation resource type not on the allowlist.
InvalidReference
A ComponentRef string (semver range or pinned+digest form) failed
to parse.
SlotConflict
The same behavior-relevant slot (kind+name) carried different tested values across components during aggregation.
Layout
An OCI Image Layout on disk was malformed or incomplete (missing
oci-layout, missing index.json, missing referenced blob, etc.).
ConfigSlotViolation
A server config declared or supplied a config slot that violates the package’s slot contract (an undeclared key, a missing required key, a key whose shape does not match its declared slot type).
key names the offending config KEY and reason describes the
violation. Neither ever carries the key’s VALUE — a config slot may
name a secret, and an error message is the wrong place for one.
AttestationSubjectMismatch
An attestation’s subject digest does not name the package it was being packed into: the supplied subject differs from the would-be UNATTESTED manifest digest of the very package under construction.
Returned by pack_server BEFORE its first blob write, which is what
makes “an attestation attached to the wrong package” unrepresentable in
a produced layout rather than merely reported afterwards.
Distinct from PackageError::DigestMismatch on purpose, and the two
must never be merged: a digest mismatch means the BYTES are corrupt,
while a subject mismatch means the bytes are fine and the CLAIM is
wrong.
supplied and computed are both sha256:<hex> digest strings, and
this variant carries nothing else. It never carries attestation payload
bytes, an issuer, or any other attestation material — the same rule
PackageError::ConfigSlotViolation’s rustdoc sets for this crate,
applied to a payload that is opaque platform-owned data this crate has
deliberately never parsed.
§Version consequence
PackageError is NOT #[non_exhaustive], so adding this variant is a
breaking change for every downstream match over it. Plan 122-08 owns
the version number that names that break; this crate publishes nothing
on its own account.
Fields
AttestationAnnotationInvalid
An attestation’s annotation value cannot survive this crate’s canonical JSON form, so packing it would produce a manifest no JSON parser can read back.
Canonical JSON (OLPC/TUF, which olpc-cjson implements and this crate’s
canonicalize uses) escapes ONLY " and \. A C0 control character
(U+0000–U+001F) in any string it emits is written LITERALLY, and RFC 8259
forbids an unescaped control character inside a JSON string — so the
manifest bytes would be invalid JSON. The package would pack cleanly and
then fail to unpack, here and in every other OCI tool.
Refused BEFORE the first blob write, for the same reason
PackageError::AttestationSubjectMismatch is: an unreadable package is
worse to produce and diagnose later than to refuse now. Attestation
annotation values arrive from the issuing platform rather than from this
repo, which is precisely why they are validated rather than trusted.
annotation names the offending annotation KEY and reason describes
the offending code point and where it sits. Neither ever carries the
annotation’s VALUE — the same rule
PackageError::ConfigSlotViolation sets, applied to untrusted input
that may be arbitrarily long or itself hostile to a terminal.
§Version consequence
PackageError is NOT #[non_exhaustive], so adding this variant is a
breaking change for every downstream match over it. Plan 122-08 owns
the version number that names that break, together with the sibling
break PackageError::AttestationSubjectMismatch introduced.
Trait Implementations§
Source§impl Debug for PackageError
impl Debug for PackageError
Source§impl Display for PackageError
impl Display for PackageError
Source§impl Error for PackageError
impl Error for PackageError
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()