{ "$id": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Caught Object Report JSON", "description": "A JS caught object representation. Default implementation is https://www.npmjs.com/package/caught-object-report-json.", "$defs": { "BASE_PROPERTIES_MIXIN": { "$id": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json/$defs/BASE_PROPERTIES_MIXIN", "type": "object", "properties": { "occurrence_id": { "description": "Root only. Identifies this occurrence: from the call, from a configured source, or a generated CORJ_ id.", "type": "string", "pattern": "^[\\x21-\\x7e]{1,128}$" }, "fingerprint": { "description": "Root only. Equal for failures of the same kind from the same place. fp1_ plus 32 hex characters, or a caller-supplied token.", "type": "string", "pattern": "^[\\x21-\\x7e]{1,64}$" }, "truncated": { "description": "Present when content or child reports were omitted to meet the configured whole-report size limit. On the root of an array report, this flag applies to the entire array.", "const": true }, "instanceof_error": { "description": "Base property. Result of `caught instanceof Error`. Omitted when it holds the expected value `true`; a missing field means `true`.", "type": "boolean" }, "typeof": { "description": "Base property. Result of `typeof caught`. Omitted when it holds the expected value \"object\"; a missing field means \"object\".", "enum": [ "undefined", "object", "boolean", "number", "bigint", "string", "symbol", "function" ] }, "constructor_name": { "description": "Optional base property. Result of `caught.constructor.name`. Not set if `caught` does not have a `constructor.name`. Set to `null` if accessing `caught.constructor.name` throws. Omitted together with `as_string` and `message` when the first line of `stack` is exactly `constructor_name + \": \" + message` (or `constructor_name` alone for an empty message); when `as_string` is absent and both `constructor_name` and `message` are absent, a reader parses them from that line at the first `\": \"`.", "oneOf": [ { "type": "null" }, { "type": "string" } ] }, "message": { "description": "Optional base property. Result of `caught.message`. Not set if `caught` does not have a `message`. Set to `null` if accessing `caught.message` throws. Omitted together with `as_string` and `constructor_name` when the first line of `stack` is exactly `constructor_name + \": \" + message`; see `constructor_name`.", "oneOf": [ { "type": "null" }, { "type": "string" } ] }, "as_string": { "description": "Base property. String representation of `caught` created using the format in `as_string_format` described in this schema. Set to `null` if creating string representation throws. Omitted when it equals the first line of `stack`; a missing field means the first line of `stack` (the first element when `stack` is an array). It is kept when `constructor_name` and `message` are both absent from the caught object although the line would parse, so that a reader does not derive fields the object never had.", "oneOf": [ { "type": "null" }, { "type": "string" } ] }, "as_json": { "description": "Base property. JSON representation of `caught` created using the format in field `as_json_format` described in this schema. The default implementation shares a configurable whole-report size budget across all fields and children (100,000 UTF-8 bytes by default) and marks partial values with [truncated]. Set to `null` if creating JSON representation throws. Omitted when it holds the expected value `{}` (an object without enumerable properties, which is what a plain `Error` produces); a missing field means `{}`.", "oneOf": [ { "type": "null" }, { "type": "number" }, { "type": "string" }, { "type": "boolean" }, { "type": "array" }, { "type": "object" } ] }, "stack": { "description": "Optional base property. Result of `caught.stack`. Not set if `caught` does not have a string `stack`. Set to `null` if accessing `caught.stack` throws. The default implementation stores `stack.split(\"\\n\")` as an array of lines (`parseStackToArray`, on by default); the raw string is stored when that option is off.", "oneOf": [ { "type": "null" }, { "type": "string" }, { "type": "array", "items": { "type": "string" } } ] }, "children_omitted": { "description": "Optional base property. Present when this node has child sources that were not reported: \"max_depth\" for the maxDepth option, \"max_children\" for the maxChildren option, \"max_size\" for the maxReportSize option, \"not_inspected\" when a children source sits behind an accessor that the inspection option would not invoke, \"redacted\" when the redact policy excluded it.", "enum": [ "max_depth", "max_children", "max_size", "not_inspected", "redacted" ] }, "v": { "description": "Optional root property. A version of report, added by the metadata option. `corj/v0.14` marks a report that omits expected values; the complete form is `corj/v0.14-full`.", "enum": ["corj/v0.14"] }, "as_string_format": { "description": "Optional base property. A format of `as_string` field. \"String\" is the result of `String(caught)`, \".toCorjAsString\" the result of the caught object's own hook, and \"derived\" a value rebuilt from property descriptors without calling any method, which is what the `no-invoke` inspection mode produces. Omitted when it holds the expected value \"String\".", "oneOf": [ { "enum": [".toCorjAsString", "String", "derived"] } ] }, "as_json_format": { "description": "Optional base property. A format of `as_json` field. Omitted when it holds the expected value \"safe-stable-stringify-with-length-limit\".", "oneOf": [ { "enum": [ ".toCorjAsJson", "safe-stable-stringify-with-length-limit" ] } ] }, "children_sources": { "description": "Optional base property. Root only. Array of property names of caught object to collect into `children` property. Omitted when it holds the expected value [\"cause\", \"errors\"].", "type": "array", "items": { "type": "string" } }, "context": { "description": "Root only. Caller data rendered as JSON; paths inside it start at $context." }, "context_omitted": { "description": "Root only. The context was dropped to meet maxReportSize.", "const": "max_size" }, "reporting_errors": { "description": "Root only. Failures met while this report was produced.", "type": "array", "maxItems": 8, "items": { "$ref": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json/$defs/REPORTING_ERROR" } }, "reporting_errors_omitted": { "description": "Root only. The reporting errors were dropped to meet maxReportSize.", "const": "max_size" } }, "description": "Base properties shared by all report objects. Since corj/v0.12 the default implementation omits fields that hold their expected value (see each property description). A missing field must be read as its expected value; `null` still means that producing the value failed." }, "REPORTING_ERROR": { "$id": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json/$defs/REPORTING_ERROR", "description": "One failure met while a report was produced. The same shape reaches the onError handler.", "type": "object", "required": ["stage", "path", "error"], "additionalProperties": false, "properties": { "stage": { "description": "Where the failure happened.", "enum": [ "prop-access", "as_string", "as_json", "children", "limit", "redact", "warning", "other" ] }, "path": { "description": "JSONPath of the value. `$` is the caught root; `$context` and other named roots are separate documents.", "type": "string" }, "key": { "description": "The report field being produced, when there is one.", "type": "string" }, "prop": { "description": "The property of the caught object being read, when there is one.", "type": "string" }, "error": { "description": "Text describing the failure, scrubbed by the redaction policy and cut to 256 characters.", "type": "string", "maxLength": 256 } } }, "REPORT_OBJECT_PROPERTIES_MIXIN": { "$id": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json/$defs/REPORT_OBJECT_PROPERTIES_MIXIN", "type": "object", "properties": { "children": { "description": "Optional root property. Every nested error found through `children_sources`, flattened breadth-first. An object that appears more than once in the tree is reported once; later occurrences reference its `id` from `child_ids`.", "type": "array", "items": { "allOf": [ { "$ref": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json/$defs/BASE_PROPERTIES_MIXIN" }, { "$ref": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json/$defs/REPORT_OBJECT_IN_ARRAY_PROPERTIES_MIXIN" } ] } } } }, "REPORT_OBJECT_IN_ARRAY_PROPERTIES_MIXIN": { "$id": "https://raw.githubusercontent.com/dany-fedorov/caught-object-report-json/main/schema-versions/corj/v0.14/definitions.json/$defs/REPORT_OBJECT_IN_ARRAY_PROPERTIES_MIXIN", "type": "object", "required": ["id", "path", "level"], "properties": { "id": { "description": "Required array-element property. String id unique for this report, from the makeReportId option. The root is \"root\" by default.", "type": "string" }, "path": { "description": "Required array-element property. JSONPath from top-level caught object.", "type": "string" }, "level": { "description": "Required array-element property. Level of this object in the tree of nested error objects. Top-level is 0.", "type": "number" }, "child_ids": { "description": "Optional array-element property. IDs of the direct children of this node. A reference to the root uses the root id. Absent when there are none.", "type": "array", "items": { "type": "string" } } } } } }