A machine-readable index of this documentation for AI agents is available at https://kubevela.io/llms.txt. Markdown versions of documentation pages are available by appending .md to their URLs.
Skip to main content
Version: Next

Expectations and Errors

How a case states what it expects: the matching rules, the error categories, and the attributes that label, park or mark a case.

Expectations​

An expectation passes when it subsumes the result: fields it names must be present and match, and fields it does not name are ignored.

FormMeaning
f: vf is present and matches v, which may be a CUE constraint such as =~"^nginx", >2 or !=3.
f?: _|_f is absent.
[a, b]A list of exactly these elements, in order.
[a, b, ...]A list that starts with these elements.
f: {...} @exact()f has no fields beyond those given.
f: ... @not()Passes unless f is present and matches.
f: [...] @contains()Each element given matches a different element of f, in any order.
f: [...] @contains() @not()None of the elements given is present.

CUE's close() has no special meaning in an expectation. Attributes go on a field, not on a list element. An @exact(), @not() or @contains() on a hidden field that the expectation only references is a load error.

Errors​

expect.error is either a string constraint matched against the whole message, such as error: =~"replicas", or a struct of messages by category:

CategoryHolds
messageThe whole message.
userWhat the definition raised through errs.
parameterParameter validation errors.
templateThe template's other errors, and any other render failure.
statusErrors evaluating health, message or details.
schemaHow a source's output does not fit its schema.

Each category is a list of messages; one error can produce several, so [=~"tier", ...] expects at least one. A category is present only when it has messages, so template?: _|_ asserts the template was fine. Any other field is a load error. A case that expects an error expects nothing else.

Attributes​

AttributePlacedEffect
@label(a, b:c)after a case, inside one, inside a struct it is built from, or at the top of the fileLabels for --label-filter. Every case is also labelled with its kind (component, trait, policy, application-policy, addon, workflow-step, source), what it does (render, status, exec), and upgrade when marked @upgrade.
@pending(reason)as @labelThe case loads but does not run, and is counted as pending. Under --check-pending it runs, and fails if it passes, since the marker is stale.
@upgrade(reason="...")as @labelA known dependency on KubeVela's CUE upgrader. A case that fails as written is retried with the controller's default rewrites, plus any named, as in @upgrade(generic-default-guard, reason="..."), and counted as upgraded. It fails once it passes as written, until the marker is removed. Under --fail-on-upgrade there is no retry, so a case that fails as written fails.
@before(), @beforeEach(), @afterEach(), @after()on a top-level field, hidden or notMakes the field a hook.