Skip to main content

Replay Failed Executions

Replaying failed executions programmatically

Errors are inevitable in software integrations.

  • A third-party API may be unavailable when your instance attempts to access it. While retry can address brief outages, it does not handle scenarios where the API is down for extended periods.
  • A third party may begin sending data in an unexpected format.
  • Your instance may encounter other edge cases that are not handled gracefully.

Regardless of the error's cause, it is useful to re-run your instance with the exact same input data after the third-party API is restored or after you have updated your integration to handle new data formats.

Replay allows you to re-execute a previous run's data through your instance. This can be performed easily via Prismatic's GraphQL API.

Querying for failed executions

First, query an instance for failed executions. You can find an instance's ID in your browser's URL bar or via the API.

Filter for executions where error_Isnull: false (i.e., executions that encountered an error). To exclude replays, include replayForExecution_Isnull: true. To fetch replays that have since succeeded, use replays(error_Isnull: true):

Query for Failed Executions
query getFailedExecutions($instanceId: ID!, $startCursor: String) {
executionResults(
instance: $instanceId
error_Isnull: false
replayForExecution_Isnull: true
after: $startCursor
) {
nodes {
id
startedAt
replays(error_Isnull: true) {
nodes {
id
startedAt
}
}
error
}
pageInfo {
hasNextPage
endCursor
}
}
}
Query Variables
{
"instanceId": "SW5zdGFuY2U6ZGVkZDQ3ZjQtNmQ4OC00NjJmLWE5YmYtNWM1OGNiMTg0MDAy",
"startCursor": ""
}
Try It Out ❯

If there are multiple pages of executions (more than 100), use the endCursor as the startCursor to paginate results.

The GraphQL API will return failed executions for the instance, along with any successful replays:

{
"data": {
"instance": {
"executionResults": {
"nodes": [
{
"id": "SW5zdGFuY2VFeGVjdXRpb25SZXN1bHQ6NjBkZDliOWMtOGIyOS00NDQyLWFkNDctMjZkZTg5Y2NlNWM5",
"startedAt": "2023-07-26T17:18:15.886806+00:00",
"replays": {
"nodes": []
},
"error": "Unable to connect to API"
},
{
"id": "SW5zdGFuY2VFeGVjdXRpb25SZXN1bHQ6MmYxNTcxZTktNDVmOS00Mzc2LTg2OGUtMTJkNjZkNDhiNzRl",
"startedAt": "2023-07-26T17:18:13.800335+00:00",
"replays": {
"nodes": [
{
"id": "SW5zdGFuY2VFeGVjdXRpb25SZXN1bHQ6N2U1MDBkZTgtY2ZmYS00NWY5LWI0OGYtNGU1YjU2YWMzMzFh",
"startedAt": "2023-07-26T17:28:10.003443+00:00"
}
]
},
"error": "Unable to connect to API"
}
]
}
}
}
}

Replaying failed executions programmatically

With the IDs of failed executions, issue a replayExecution mutation for each one that does not have a successful replay:

Replay a failed execution
mutation myReplayExecution($executionId: ID!) {
replayExecution(input: {id: $executionId}) {
instanceExecutionResult {
id
}
errors {
field
messages
}
}
}
Query Variables
{
"executionId": "SW5zdGFuY2VFeGVjdXRpb25SZXN1bHQ6NjBkZDliOWMtOGIyOS00NDQyLWFkNDctMjZkZTg5Y2NlNWM5"
}
Try It Out ❯

The mutation returns the ID of the new execution. You can then query the API for that execution to verify success or perform further debugging if needed.

For a script that automates these GraphQL calls, see our examples GitHub repo.

For more information, see the API docs.