Skip to content

Commit 67defa0

Browse files
Add route handler for Workflow Diagnostics (#943)
Add diagnoseWorkflow route handler for Workflow Diagnostics, that calls DiagnoseWorkflowExecution and then repeatedly queries the diagnostics workflow for the result
1 parent d11603c commit 67defa0

File tree

9 files changed

+648
-0
lines changed

9 files changed

+648
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { type NextRequest } from 'next/server';
2+
3+
import { diagnoseWorkflow } from '@/route-handlers/diagnose-workflow/diagnose-workflow';
4+
import { type RouteParams } from '@/route-handlers/fetch-workflow-query-types/fetch-workflow-query-types.types';
5+
import { routeHandlerWithMiddlewares } from '@/utils/route-handlers-middleware';
6+
import routeHandlersDefaultMiddlewares from '@/utils/route-handlers-middleware/config/route-handlers-default-middlewares.config';
7+
8+
export async function GET(
9+
request: NextRequest,
10+
options: { params: RouteParams }
11+
) {
12+
return routeHandlerWithMiddlewares(
13+
diagnoseWorkflow,
14+
request,
15+
options,
16+
routeHandlersDefaultMiddlewares
17+
);
18+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
export const mockWorkflowDiagnosticsResult = {
2+
DiagnosticsResult: {
3+
Timeouts: null,
4+
Failures: {
5+
Issues: [
6+
{
7+
IssueID: 0,
8+
InvariantType: 'Activity Failed',
9+
Reason:
10+
'The failure is because of an error returned from the service code',
11+
Metadata: {
12+
Identity: 'test-worker@test-host@test-domain@test-workflow@12345',
13+
ActivityType: 'main.helloWorldActivity',
14+
ActivityScheduledID: 43,
15+
ActivityStartedID: 156,
16+
},
17+
},
18+
{
19+
IssueID: 1,
20+
InvariantType: 'Activity Failed',
21+
Reason:
22+
'The failure is because of an error returned from the service code',
23+
Metadata: {
24+
Identity: 'test-worker@test-host@test-domain@test-workflow@12345',
25+
ActivityType: 'main.helloWorldActivity',
26+
ActivityScheduledID: 29,
27+
ActivityStartedID: 234,
28+
},
29+
},
30+
{
31+
IssueID: 2,
32+
InvariantType: 'Activity Failed',
33+
Reason:
34+
'The failure is because of an error returned from the service code',
35+
Metadata: {
36+
Identity: 'test-worker@test-host@test-domain@test-workflow@12345',
37+
ActivityType: 'main.helloWorldActivity',
38+
ActivityScheduledID: 82,
39+
ActivityStartedID: 234,
40+
},
41+
},
42+
{
43+
IssueID: 3,
44+
InvariantType: 'Activity Failed',
45+
Reason:
46+
'The failure is because of an error returned from the service code',
47+
Metadata: {
48+
Identity: 'test-worker@test-host@test-domain@test-workflow@12345',
49+
ActivityType: 'main.helloWorldActivity',
50+
ActivityScheduledID: 102,
51+
ActivityStartedID: 411,
52+
},
53+
},
54+
{
55+
IssueID: 4,
56+
InvariantType: 'Workflow Failed',
57+
Reason:
58+
'The failure is because of an error returned from the service code',
59+
Metadata: {
60+
Identity: 'test-worker@test-host@test-domain@test-workflow@12345',
61+
ActivityType: '',
62+
ActivityScheduledID: 0,
63+
ActivityStartedID: 0,
64+
},
65+
},
66+
],
67+
RootCause: [
68+
{
69+
IssueID: 0,
70+
RootCauseType:
71+
'There is an issue in the worker service that is causing a failure. Check identity for service logs',
72+
Metadata: null,
73+
},
74+
{
75+
IssueID: 1,
76+
RootCauseType:
77+
'There is an issue in the worker service that is causing a failure. Check identity for service logs',
78+
Metadata: null,
79+
},
80+
{
81+
IssueID: 2,
82+
RootCauseType:
83+
'There is an issue in the worker service that is causing a failure. Check identity for service logs',
84+
Metadata: null,
85+
},
86+
{
87+
IssueID: 3,
88+
RootCauseType:
89+
'There is an issue in the worker service that is causing a failure. Check identity for service logs',
90+
Metadata: null,
91+
},
92+
{
93+
IssueID: 4,
94+
RootCauseType:
95+
'There is an issue in the worker service that is causing a failure. Check identity for service logs',
96+
Metadata: null,
97+
},
98+
],
99+
Runbooks: [
100+
'https://cadenceworkflow.io/docs/workflow-troubleshooting/activity-failures/',
101+
],
102+
},
103+
Retries: null,
104+
},
105+
DiagnosticsCompleted: true,
106+
};

0 commit comments

Comments
 (0)