Skip to content

[WIP] Update to Error Handling #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions roadmap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ _Status description:_
| ✔️| Apply fixes to auth spec schema [workflow schema](https://github.com/serverlessworkflow/specification/tree/main/schema) |
| ✔️| Update the `dataInputSchema` top-level property by supporting the assignment of a JSON schema object [workflow schema](https://github.com/serverlessworkflow/specification/tree/main/specification.md#workflow-definition-structure) |
| ✔️| Add the new `WORKFLOW` reserved keyword to workflow expressions |
| ✔️| Update worflow error handling |
| ✔️| Make action name a required parameter |
| ✔️| Add name property to data filters |
| ✏️️| Add inline state defs in branches | |
| ✏️️| Update rest function definition | |
| ✏️️| Add "completedBy" functionality | |
Expand Down
296 changes: 296 additions & 0 deletions schema/errordata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
{
"$id": "https://serverlessworkflow.io/schemas/0.8/workflow.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Serverless Workflow specification - workflow schema",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"action",
"timeout",
"datafilter",
"state"
],
"description": "Error type",
"default": "state"
},
"description": {
"type": "string",
"description": "Error description"
},
"cause": {
"description": "Error Cause",
"$ref": "#/definitions/cause"
},
"source": {
"description": "Error Source",
"$ref": "#/definitions/source"
},
"error": {
"description": "Error Info",
"$ref": "#/definitions/error"
},
"metadata": {
"$ref": "common.json#/definitions/metadata",
"description": "Metadata information"
}
},
"required": [
"type",
"cause",
"source",
"error"
],
"definitions": {
"cause": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "Cause type"
},
"message": {
"type": "string",
"description": "Cause message"
},
"retryable": {
"type": "boolean",
"description": "Cause retryable",
"default": true
},
"metadata": {
"$ref": "common.json#/definitions/metadata",
"description": "Metadata information"
}
},
"required": [
"type",
"message"
]
},
"source": {
"type": "object",
"properties": {
"workflowInfo": {
"description": "Source Workflow Info",
"$ref": "#/definitions/workflowinfo"
},
"stateInfo": {
"description": "Source State Info",
"$ref": "#/definitions/stateinfo"
},
"metadata": {
"$ref": "common.json#/definitions/metadata",
"description": "Metadata information"
}
},
"required": [
"workflowInfo",
"stateInfo"
]
},
"workflowinfo": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Workflow id"
},
"key": {
"type": "string",
"description": "Workflow key"
},
"version": {
"type": "string",
"description": "Workflow version"
},
"name": {
"type": "string",
"description": "Workflow name"
},
"metadata": {
"$ref": "common.json#/definitions/metadata",
"description": "Metadata information"
}
},
"required": [
"id"
]
},
"stateinfo": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "State id"
},
"name": {
"type": "string",
"description": "State name"
},
"type": {
"type": "string",
"enum": [
"sleep",
"event",
"operation",
"parallel",
"switch",
"inject",
"foreach",
"callback"
],
"description": "State type"
},
"metadata": {
"$ref": "common.json#/definitions/metadata",
"description": "Metadata information"
}
},
"required": [
"name",
"type"
]
},
"error": {
"type": "object",
"properties": {
"description": {
"type": "string",
"description": "Error description"
},
"timeoutInfo": {
"description": "Error Timeout Info",
"$ref": "#/definitions/timeoutinfo"
},
"actionInfo": {
"description": "Error Action Info",
"$ref": "#/definitions/actioninfo"
},
"branchInfo": {
"description": "Error Branch Info",
"$ref": "#/definitions/branchinfo"
},
"eventInfo": {
"description": "Error Event Info",
"$ref": "#/definitions/eventinfo"
},
"filterInfo": {
"description": "Error Data Filter Info",
"$ref": "#/definitions/filterinfo"
},
"metadata": {
"$ref": "common.json#/definitions/metadata",
"description": "Metadata information"
}
},
"required": [
]
},
"timeoutinfo": {
"type": "object",
"properties": {
"description": {
"type": "string",
"description": "Timeout Error description"
},
"value": {
"type": "string",
"description": "Timeout value"
},
"type": {
"type": "string",
"enum": [
"state",
"action",
"branch",
"event"
],
"description": "Timeout type"
},
"metadata": {
"$ref": "common.json#/definitions/metadata",
"description": "Metadata information"
}
},
"required": [
"type"
]
},
"actioninfo": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Action name"
},
"functionRef": {
"type": "string",
"description": "Function ref"
},
"eventRef": {
"type": "string",
"description": "Event ref"
},
"subflowRef": {
"type": "string",
"description": "Sublfow ref"
}
},
"required": [
"name"
]
},
"branchinfo": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Branch name"
}
},
"required": [
"name"
]
},
"eventinfo": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Event name"
},
"source": {
"type": "string",
"description": "Event name"
},
"type": {
"type": "string",
"description": "Event name"
}
},
"required": [
"name",
"source",
"type"
]
},
"filterinfo": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Filter name"
},
"expression": {
"type": "string",
"description": "Filter name"
}
},
"required": [
"name"
]
}
}
}
4 changes: 2 additions & 2 deletions schema/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"description": "Domain-specific error name",
"minLength": 1
},
"code": {
"expression": {
"type": "string",
"description": "Error code. Can be used in addition to the name to help runtimes resolve to technical errors/exceptions. Should not be defined if error is set to '*'",
"description": "Workflow expression that filters workflow error data",
"minLength": 1
},
"description": {
Expand Down
27 changes: 27 additions & 0 deletions schema/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,22 +480,34 @@
"description": "Expression, if defined, must evaluate to true for this action to be performed. If false, action is disregarded",
"type": "string",
"minLength": 1
},
"onErrors": {
"type": "array",
"description": "Action error handling definitions",
"items": {
"type": "object",
"$ref": "#/definitions/error"
},
"additionalItems": false
}
},
"additionalProperties": false,
"oneOf": [
{
"required": [
"name",
"functionRef"
]
},
{
"required": [
"name",
"eventRef"
]
},
{
"required": [
"name",
"subFlowRef"
]
}
Expand Down Expand Up @@ -1840,6 +1852,11 @@
},
"statedatafilter": {
"type": "object",
"name": {
"type": "string",
"description": "Filter name",
"minLength": 1
},
"properties": {
"input": {
"type": "string",
Expand All @@ -1856,6 +1873,11 @@
"eventdatafilter": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Filter name",
"minLength": 1
},
"useData": {
"type": "boolean",
"description": "If set to false, event payload is not added/merged to state data. In this case 'data' and 'toStateData' should be ignored. Default is true.",
Expand All @@ -1876,6 +1898,11 @@
"actiondatafilter": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Filter name",
"minLength": 1
},
"fromStateData": {
"type": "string",
"description": "Workflow expression that selects state data that the state action can use"
Expand Down
Loading