- integrations
- Python
- ocx_sdk
EnvReport, ErrorEnvelope
EnvReportclassdataclass#
Re-exported from
ocx_sdk._resultsView sourcecomposemethod#
def compose(base: Mapping[str, str] | None = None) -> ComposedEnvFold these entries onto an environment.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
base | Mapping[str, str] | None | None | What 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.
.mappingis 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 fromocx envshould not reach that; a hand-built one can.
from_jsonmethodclassmethod#
def from_json(raw: str, *, base: Mapping[str, str] = _EMPTY) -> EnvReportParse ocx --format json env (or package env) output.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
raw | str | required | Captured stdout. |
base | Mapping[str, str] | _EMPTY | The 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 sourceclass 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
| Name | Type | Description |
|---|---|---|
schema_version | int | The envelope’s own version; 1 for every 0.6 binary. |
command | str | The canonical command string, e.g. "package claim". |
exit_code | int | The exit status the process returned. |
kind | str | The coarse category, snake_case ("data_error", "auth_error", …). |
message | str | The outermost message of the error chain. |
detail | str | None | The fine-grained variant slug, when ocx assigned one. |
remediation | str | None | A 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. |
context | Mapping[str, Any] | Structured context (identifiers, digests, URLs), untyped. |