Documentation
¶
Overview ¶
Package errors provides sentinel errors and structured error types for OPM.
Configuration validation errors are CUE-native — see cuelang.org/go/cue/errors for the canonical interface and helpers (Errors, Positions, Print). The library does not wrap CUE diagnostics in custom Go-typed projections, nor does it ship a presentation-layer formatter; frontends walk the CUE error tree and render however their consumer requires.
Index ¶
Constants ¶
const ( // MaterializeKindCatalog marks a subscription-resolution failure: a // catalog path could not be enumerated, pulled, decoded, or its // transformers conflicted. Subscription and Version are populated. MaterializeKindCatalog = "catalog" // MaterializeKindCoreSchema is reserved for core-schema load failures // surfaced through the same shape. Materialize does not yet emit it; // when it does, Subscription is empty. MaterializeKindCoreSchema = "core-schema" )
MaterializeError kinds. Kind discriminates where in the Materialize flow a failure originated so frontends can route diagnostics without string matching (D24).
Variables ¶
var ( // ErrValidation indicates a CUE schema validation failure. ErrValidation = errors.New("validation error") // ErrConnectivity indicates a network connectivity issue. ErrConnectivity = errors.New("connectivity error") // ErrPermission indicates insufficient permissions. ErrPermission = errors.New("permission denied") // ErrNotFound indicates a resource, module, or file was not found. ErrNotFound = errors.New("not found") )
Sentinel errors for known conditions.
Functions ¶
Types ¶
type IdentityError ¶
type IdentityError struct {
// Artifact discriminates the read site: "module" | "catalog".
Artifact string
// Field names the mismatched identity field: "path" | "version".
Field string
// Declared is the value the artifact's metadata claims.
Declared string
// Fetched is the coordinate/tag the artifact was actually fetched by.
Fetched string
// Coordinate is the full fetched coordinate for context,
// e.g. "opmodel.dev/catalogs/opm@v2 v2.0.0-alpha.3".
Coordinate string
}
IdentityError reports a mismatch between an artifact's declared identity and the coordinate it was fetched by (0010 D11), including the version clause (D9): the kernel is the version label's verifier, never its source. It is emitted at the two library read sites that hold both a fetched coordinate and decoded metadata — module acquire (opm/helper/loader/registry) returns it bare; catalog materialize (opm/materialize) wraps it in a *MaterializeError (Kind "catalog") as Cause, so frontends route on it via errors.As either way.
func (IdentityError) Error ¶
func (e IdentityError) Error() string
Error names both values (D11: "a typed error naming both"). Value receiver: the condition is a comparison, not a wrapped failure, so there is no Cause and no Unwrap.
type MaterializeError ¶
type MaterializeError struct {
// Kind is one of MaterializeKindCatalog or MaterializeKindCoreSchema.
Kind string
// Subscription is the catalog subscription path that failed. Empty when
// Kind == MaterializeKindCoreSchema.
Subscription string
// Version is the resolved or attempted version, when known.
Version string
// Cause is the wrapped underlying error.
Cause error
}
MaterializeError is a structured failure from the platform Materialize flow. It carries a Kind discriminator plus the subscription path and the attempted/resolved version, and wraps the underlying cause so callers can reach it via errors.Unwrap / errors.As.
func (*MaterializeError) Error ¶
func (e *MaterializeError) Error() string
func (*MaterializeError) Unwrap ¶
func (e *MaterializeError) Unwrap() error
type MissingFQN ¶
type MissingFQN struct {
// Instance is the ModuleInstance name the demanding component belongs to.
// Was: Release
Instance string
// Component is the component name that demanded the FQN.
Component string
// FQN is the demanded primitive FQN with no transformer requiring it.
FQN string
// Alternatives is the same-modulePath/name FQN set materialized on the
// platform at other versions, sorted by SemVer. May be empty.
Alternatives []string
}
MissingFQN is the hard structured diagnostic for a demanded primitive FQN that no transformer on the materialized platform requires (its #matchers bucket is empty). It is distinct from the soft non-match recorded when a transformer is found but its requiredLabels are not satisfied.
One MissingFQN is recorded per (Instance, Component, FQN) triple. Alternatives lists every primitive FQN sharing the same modulePath/name at other versions that the platform did materialize, in contract-key order (the kube-aware apiVersion ladder, 0010 D34/D4) — a hint that a different version of the same primitive is available.
func (MissingFQN) Error ¶
func (e MissingFQN) Error() string
type TransformError ¶
TransformError indicates transformer execution failed.
func (*TransformError) Component ¶
func (e *TransformError) Component() string
Component returns the component name where the error occurred.
func (*TransformError) Error ¶
func (e *TransformError) Error() string
func (*TransformError) Unwrap ¶
func (e *TransformError) Unwrap() error
type UnifyError ¶
type UnifyError struct {
// Component is the component whose body diverged.
Component string
// FQN is the primitive FQN at which the bodies conflicted.
FQN string
// Cause is the verbatim CUE error tree, reachable via errors.As for
// cuelang.org/go/cue/errors.Error.
Cause error
}
UnifyError is the structured diagnostic for a unification failure between a consumer component's primitive body and a candidate transformer's required primitive body at the same FQN (the always-unify rung).
Cause carries the CUE error tree verbatim — no Go-side reformatting — so a frontend can walk it via [Unwrap] / errors.As for a cuelang.org/go/cue/errors.Error and render the native `conflicting values "X" and "Y": file:line file:line` message.
func (UnifyError) Error ¶
func (e UnifyError) Error() string
func (UnifyError) Unwrap ¶
func (e UnifyError) Unwrap() error
type UnresolvedDemand ¶
type UnresolvedDemand struct {
// Component is the component whose demand went unresolved.
Component string
// FQN is the demanded contract key.
FQN string
// Kind is "resource" or "trait".
Kind string
// Alternatives is the same-base contract-key set the platform does
// implement, in contract-key order (kube-aware apiVersion ladder,
// D34/D4). Empty when nothing implements the contract.
Alternatives []string
// Disqualified carries, when candidates existed, the unify failures that
// disqualified them. Predicate-disqualified candidates contribute no
// entry (there is no unify cause to carry).
Disqualified []UnifyError
// UnstatedPosture marks a trait demand that failed closed because its
// effective `optional` was not concrete — the declaring catalog stated
// no posture, so the trait is treated as load-bearing (D28).
UnstatedPosture bool
}
UnresolvedDemand is the structured diagnostic for a demanded contract key the platform does not resolve (0010 D28): the matcher index holds no candidate for it, or every candidate was disqualified (by unification or by predicate). Every declared resource is a required demand; a trait demand is unresolved only when its effective `optional` posture is load-bearing — including the fail-closed case of a posture the catalog never stated.
The D4 contract-key diagnostic is carried by Alternatives: empty means nothing on this platform implements the contract at any version; non-empty means the contract base is implemented at a different apiVersion only.
func (UnresolvedDemand) Error ¶
func (e UnresolvedDemand) Error() string
type UnresolvedDemandsError ¶
type UnresolvedDemandsError struct {
// Demands is the full unresolved-demand set, in plan order.
Demands []UnresolvedDemand
}
UnresolvedDemandsError aggregates every unresolved demand of a plan into the typed error Plan/Compile fail with (D28). Each demand is reachable via Unwrap() []error for errors.As routing.
func (*UnresolvedDemandsError) Error ¶
func (e *UnresolvedDemandsError) Error() string
func (*UnresolvedDemandsError) Unwrap ¶
func (e *UnresolvedDemandsError) Unwrap() []error
Unwrap exposes each UnresolvedDemand so callers can route on the value type via errors.As.