Core
Errors
ViewportError, SpecError and the stable codes core raises.
Outcomes are values, failures are exceptions. A failed match, an over-budget run or an undecidable condition is a result you inspect. An exception means the input was invalid or the world broke.
ViewportError(code, message, details)is the base of every Viewport error.codeis stable API (<package>.<snake_reason>);docs_url/docsUrlpoints athttps://docs.getviewport.com/errors/<code>. In TypeScript,instanceofworks even when two copies of core are loaded.SpecErroris aViewportErrorfor invalid authored documents. It carries everySpecIssue(path,code,message,suggestion,file,line,column) and formats them asfile:line:column path: message. Did you mean "x"?.
| Code | Raised by |
|---|---|
core.spec_invalid | schema validation (parse) |
core.matcher_invalid | compile_matcher / compileMatcher, parse("matcher/v1", ...) |
core.invariant_invalid | parseInvariants / parse_invariants (@viewportai/core/invariants, viewportai.core.invariants) |
core.matcher_async | sync match on a spec that uses judge |
core.judge_unavailable | amatch / matchAsync with no judge for the requested name |
core.yaml_invalid | load_yaml / loadYaml |
core.path_invalid | parse_path / parsePath, query_path / queryPath |
core.duration_invalid | parse_duration / parseDuration |
core.json_invalid | stable_json / stableJson on NaN, Infinity or non-JSON values |
core.canonical_json_invalid | canonical_json / canonicalJson (floats, unsafe integers, non snake_case keys) |
core.jcs_invalid | jcs / jcsDigest (NaN, Infinity, lone surrogates) |
core.tool_args_invalid | a tool whose arguments fail its schema |
core.tool_args_unstable | validating a call's approved view again would change it (a non-idempotent transform); what a gate approves must be what runs |
core.tool_schema_invalid | defining a tool whose JSON Schema input_schema core cannot run |
core.tool_server_invalid | a tool server answering anything but { result }, { error: { type, message } } or nothing |
core.mask_too_late | call.mask(...) called after next(): the call's start event already holds its arguments |
core.tool_sync_in_loop | (Python) a plain def @tool called synchronously while a middleware on it waits on the event loop (tool_middleware(loop_bound=True), or one that waited before the body ran); use await tool.execute(...) on that loop |
core.redact_key_invalid | VIEWPORT_REDACT_KEY or decodeRedactKey / decode_redact_key given a malformed or weak key |
core.fake_exhausted | a fake_tool / fakeTool called more times than it has responses |
Issue codes inside SpecError (unknown_key, required, type, mixed_keys, suspicious_key,
operator_not_allowed, regex_invalid, duplicate_key, ...) are stable too, and conformance vectors pin them.