Skip to main content

PackageError

Enum PackageError 

Source
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).

Fields

§expected: String
§actual: String
§

MalformedDigest

A digest string is not well-formed (e.g. not sha256:<64-hex>).

Fields

§reason: String
§

AllowlistViolation

A deploy descriptor requested a CloudFormation resource type not on the allowlist.

Fields

§resource: String
§

InvalidReference

A ComponentRef string (semver range or pinned+digest form) failed to parse.

Fields

§reason: String
§

SlotConflict

The same behavior-relevant slot (kind+name) carried different tested values across components during aggregation.

Fields

§slot: String
§tested: String
§proposed: String
§

Layout

An OCI Image Layout on disk was malformed or incomplete (missing oci-layout, missing index.json, missing referenced blob, etc.).

Fields

§reason: String
§

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.

Fields

§reason: String
§

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

§supplied: String

The sha256:<hex> subject the caller supplied with the attestation.

§computed: String

The sha256:<hex> unattested manifest digest actually computed for the package being packed.

§

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.

Fields

§annotation: String

The annotation KEY whose value was refused, e.g. run.pmcp.attestation.issuer.

§reason: String

What is wrong with the value, naming the code point and its byte offset but never reproducing the value itself.

Trait Implementations§

Source§

impl Debug for PackageError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PackageError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for PackageError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for PackageError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for PackageError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.