Skip to content
ocx
install

EnvReport, ErrorEnvelope

EnvReportclassdataclass#

Re-exported from ocx_sdk._resultsView source

composemethod#

def compose(base: Mapping[str, str] | None = None) -> ComposedEnv

Fold these entries onto an environment.

Parameters

NameTypeDefaultDescription
baseMapping[str, str] | NoneNoneWhat to fold onto. Defaults to the environment the producing call ran under, so composing a report from a hermetic handle stays hermetic.

Returns

ComposedEnv
The merged environment. .mapping is the non-invasive form;
ComposedEnv
.activate() applies it to the whole process.

Raises

ValueError
Two list contributions to one key disagree about the separator, or a value is edged by the one it folds with (_envmodel.merge). ocx validates its own [env] before emitting it, so a report parsed from ocx env should not reach that; a hand-built one can.

from_jsonmethodclassmethod#

def from_json(raw: str, *, base: Mapping[str, str] = _EMPTY) -> EnvReport

Parse ocx --format json env (or package env) output.

Parameters

NameTypeDefaultDescription
rawstrrequiredCaptured stdout.
baseMapping[str, str]_EMPTYThe environment the call ran under, carried for compose. Snapshotted, so a later mutation of the source cannot rewrite what an already-parsed report composes onto.

ErrorEnvelopeclassdataclass#

Re-exported from ocx_sdk._resultsView source
class ErrorEnvelope(schema_version: int, command: str, exit_code: int, kind: str, message: str, detail: str | None = None, remediation: str | None = None, context: Mapping[str, Any] = _EMPTY)

The structured failure ocx prints under --format json (C-S1-1).

{schema_version, command, exit_code, error: {kind, detail?, message, remediation?, context}} — a contract frozen separately from the reports schema, and printed on stdout only when the failing command wrote no report of its own. error_envelope(err) is how a caller reaches it.

The exit code is still the category (_errors): kind restates it as ocx’s own vocabulary, and detail — when present — is the fine-grained slug to branch on. message is prose, free to be reworded.

Attributes

NameTypeDescription
schema_versionintThe envelope’s own version; 1 for every 0.6 binary.
commandstrThe canonical command string, e.g. "package claim".
exit_codeintThe exit status the process returned.
kindstrThe coarse category, snake_case ("data_error", "auth_error", …).
messagestrThe outermost message of the error chain.
detailstr | NoneThe fine-grained variant slug, when ocx assigned one.
remediationstr | NoneA remediation hint. Reserved upstream and never emitted by a 0.6 binary; carried so a consumer treating it as optional keeps working when it appears.
contextMapping[str, Any]Structured context (identifiers, digests, URLs), untyped.

commandattributeinstance attribute#

command: str

contextattributeclass attributeinstance attribute#

context: Mapping[str, Any] = _EMPTY