{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://errors.standardbeagle.com/schema.json",
  "title": "ErrLookup Dataset",
  "description": "Canonical schema for the err-lookup v2 error knowledge base.",
  "schemaVersion": 2,
  "definitions": {
    "ErrorEntry": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{16}$"
        },
        "repo": {
          "type": "string",
          "pattern": "^[^/\\s]+\\/[^/\\s]+$"
        },
        "slug": {
          "type": "string",
          "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"
        },
        "errorCode": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "errorMessage": {
          "type": "string",
          "minLength": 1
        },
        "messagePattern": {
          "type": "string",
          "minLength": 1
        },
        "errorType": {
          "type": "string",
          "enum": [
            "exception",
            "error_code",
            "console",
            "http",
            "validation",
            "panic"
          ]
        },
        "errorClass": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "httpStatus": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 100,
              "maximum": 599
            },
            {
              "type": "null"
            }
          ]
        },
        "severity": {
          "type": "string",
          "enum": [
            "critical",
            "error",
            "warning",
            "info"
          ]
        },
        "filePath": {
          "type": "string",
          "minLength": 1
        },
        "lineNumber": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "sourceCode": {
          "type": [
            "string",
            "null"
          ]
        },
        "sourceCodeStart": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "sourceCodeEnd": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "githubUrl": {
          "type": "string",
          "format": "uri"
        },
        "documentation": {
          "type": "string",
          "minLength": 1
        },
        "triggerScenarios": {
          "type": "string",
          "minLength": 1
        },
        "commonSituations": {
          "type": "string",
          "minLength": 1
        },
        "solutions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "exampleFix": {
          "type": [
            "string",
            "null"
          ]
        },
        "handlingStrategy": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "try-catch",
                "type-guard",
                "validation",
                "retry",
                "fallback"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "validationCode": {
          "type": [
            "string",
            "null"
          ]
        },
        "typeGuard": {
          "type": [
            "string",
            "null"
          ]
        },
        "tryCatchPattern": {
          "type": [
            "string",
            "null"
          ]
        },
        "preventionTips": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"
          }
        },
        "backgroundTag": {
          "anyOf": [
            {
              "$ref": "#/definitions/ErrorEntry/properties/tags/items"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "backgroundTagRaw": {
          "anyOf": [
            {
              "$ref": "#/definitions/ErrorEntry/properties/tags/items"
            },
            {
              "type": "null"
            }
          ]
        },
        "analyzedSha": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "analyzedAt": {
          "type": "string",
          "format": "date-time"
        },
        "contentChangedAt": {
          "anyOf": [
            {
              "$ref": "#/definitions/ErrorEntry/properties/analyzedAt"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "schemaVersion": {
          "type": "number",
          "const": 2
        }
      },
      "required": [
        "id",
        "repo",
        "slug",
        "errorCode",
        "errorMessage",
        "messagePattern",
        "errorType",
        "errorClass",
        "httpStatus",
        "severity",
        "filePath",
        "lineNumber",
        "sourceCode",
        "sourceCodeStart",
        "sourceCodeEnd",
        "githubUrl",
        "documentation",
        "triggerScenarios",
        "commonSituations",
        "solutions",
        "exampleFix",
        "handlingStrategy",
        "validationCode",
        "typeGuard",
        "tryCatchPattern",
        "preventionTips",
        "tags",
        "analyzedSha",
        "analyzedAt",
        "schemaVersion"
      ],
      "additionalProperties": false
    },
    "RepoEntry": {
      "type": "object",
      "properties": {
        "repo": {
          "type": "string",
          "pattern": "^[^/\\s]+\\/[^/\\s]+$"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "language": {
          "type": [
            "string",
            "null"
          ]
        },
        "stars": {
          "type": "integer",
          "minimum": 0
        },
        "sourceFiles": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "defaultBranch": {
          "type": "string",
          "minLength": 1
        },
        "analyzedSha": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "analyzedAt": {
          "type": "string",
          "format": "date-time"
        },
        "contentChangedAt": {
          "anyOf": [
            {
              "$ref": "#/definitions/RepoEntry/properties/analyzedAt"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "errorCount": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "repo",
        "description",
        "language",
        "stars",
        "sourceFiles",
        "defaultBranch",
        "analyzedSha",
        "analyzedAt",
        "errorCount"
      ],
      "additionalProperties": false
    }
  }
}