errors

package
v1.0.0-alpha.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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@v4 v4.0.1".
	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 one library read site that holds both a fetched coordinate and decoded metadata: module acquire (opm/helper/loader/registry) returns it bare, so frontends route on it via errors.As. A platform's catalog builds are verified structurally by core instead (0019 D5: the registry key binds to the embedded catalog's modulePath), so no catalog read site produces it.

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 MatchResult

type MatchResult struct {
	Matched       bool     `json:"matched"`
	MissingLabels []string `json:"missingLabels"`
}

MatchResult is the per-(component, transformer) verdict carried on UnmatchedComponentsError.Matches: whether the candidate matched and, when the label predicate refused it, which required labels the component's matchLabels lacked or carried with a different value. The render build reports one row per candidate its demand walk reached; a candidate the always-unify rung refused appears unmatched with no missing labels, its conflict being on the render diagnostics' Unify rows.

type OverSubscribedContractError

type OverSubscribedContractError struct {
	// Key is the provider-fulfilled contract key (a resource or trait FQN).
	Key string

	// Catalogs are the registry keys whose transformers require Key: the
	// catalog module paths (path@major) core binds each entry's embedded
	// catalog identity to. Sorted, so the refusal is deterministic.
	Catalogs []string
}

OverSubscribedContractError is the render refusal for a contract key declared `fulfilment: "provider"` on a required demand of transformers from more than one of the platform's enabled registry entries (the single-provider guard, enhancement 0010 D32 as corrected by D37; enforced inside the render build since library-render-cutover). A platform must carry exactly one provider for such a key; two is a misconfigured platform, not an arbitration.

It is carried on the kernel's render diagnostics as a row and joined into the fail-closed gate error, reachable via errors.As.

func (OverSubscribedContractError) Error

type SkewError

type SkewError struct {
	// Path is the major-qualified module path in skew.
	Path string

	// ModuleVersion is the build the instance module requires.
	ModuleVersion string

	// PlatformVersion is the build the platform module carries.
	PlatformVersion string
}

SkewError is the refuse-mode diagnostic for catalog version skew (enhancement 0019 D7/D18): the instance module's cue.mod requires a NEWER build of an OPM-namespace path than the platform module carries, and the caller configured the render to refuse rather than warn. The render stops before evaluation; the platform's build is what would have executed.

func (*SkewError) Error

func (e *SkewError) Error() string

type TransformError

type TransformError struct {
	ComponentName  string
	TransformerFQN string
	Cause          error
}

TransformError indicates transformer execution failed.

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 UnmatchedComponentsError

type UnmatchedComponentsError struct {
	// Components is the list of component names with no matching transformer.
	Components []string

	// Matches is the candidate matrix for each unmatched component: every
	// transformer the render build evaluated for it, keyed by FQN, with the
	// predicate verdict. Empty for a component no transformer was a
	// candidate for (its demands are on the unresolved diagnostics).
	Matches map[string]map[string]MatchResult
}

UnmatchedComponentsError is the render gate's refusal for components no transformer matched. It carries the per-component match matrix so a frontend can list which candidates were evaluated and why each was refused; the render build reports the unmatched set as data (kernel.RenderDiagnostics.Unmatched) and the kernel raises this error through the fail-closed gate, reachable via errors.As from *kernel.RenderError.

Each unmatched component is surfaced as a *TransformError via Unwrap(), enabling callers to use errors.As for typed handling of individual failures.

func (*UnmatchedComponentsError) Error

func (e *UnmatchedComponentsError) Error() string

func (*UnmatchedComponentsError) Unwrap

func (e *UnmatchedComponentsError) Unwrap() []error

Unwrap returns a slice of *TransformError — one per unmatched component — so that callers can use errors.As to extract per-component failure details.

Each TransformError carries the component name and the first non-matching transformer FQN. Its Cause is a plain terminal error describing the failure, not a nested UnmatchedComponentsError, to prevent infinite recursion when errors.As traverses the chain.

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 Render fails with through the gate (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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL