Skip to content
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

DT-2499 - wf reset ux improvement #2359

Merged
merged 5 commits into from
Sep 30, 2024
Merged
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
27 changes: 3 additions & 24 deletions src/lib/components/lines-and-dots/workflow-error.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
import Link from '$lib/holocene/link.svelte';
import { translate } from '$lib/i18n/translate';
import { relativeTime, timeFormat } from '$lib/stores/time-format';
import type {
PendingWorkflowTaskInfo,
WorkflowTaskFailedEventAttributes,
} from '$lib/types';
import type { PendingWorkflowTaskInfo } from '$lib/types';
import type { WorkflowTaskFailedEvent } from '$lib/types/events';
import type { WorkflowTaskFailedCause } from '$lib/types/workflows';
import { spaceBetweenCapitalLetters } from '$lib/utilities/format-camel-case';
import { formatDate } from '$lib/utilities/format-date';
import { toWorkflowTaskFailureReadable } from '$lib/utilities/screaming-enums';
import { getErrorCause } from '$lib/utilities/get-workflow-task-failed-event';

import { CategoryIcon } from './constants';

Expand All @@ -25,30 +22,12 @@

let cause: WorkflowTaskFailedCause;

function getErrorCause(
error: WorkflowTaskFailedEvent,
): WorkflowTaskFailedCause {
const {
workflowTaskFailedEventAttributes: { failure, cause },
} = error as WorkflowTaskFailedEvent & {
workflowTaskFailedEventAttributes: WorkflowTaskFailedEventAttributes;
};

if (
failure?.applicationFailureInfo?.type === 'workflowTaskHeartbeatError'
) {
return 'WorkflowTaskHeartbeatError';
}

return toWorkflowTaskFailureReadable(cause);
}

$: {
cause = getErrorCause(error);
}
</script>

{#if cause}
{#if cause && cause !== 'ResetWorkflow'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure there will be more of these cases but not gonna overthink trying to abstract that way yet. This is fine.

<Alert
icon="warning"
intent="warning"
Expand Down
78 changes: 0 additions & 78 deletions src/lib/components/workflow/workflow-typed-error.svelte

This file was deleted.

5 changes: 0 additions & 5 deletions src/lib/i18n/locales/en/typed-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ export const Strings = {
description:
'The payload has exceeded the available input size on a Signal.',
},
ResetWorkflow: {
title: 'Reset Workflow',
description:
'The system failed this Workflow Task. If a reset for this Workflow was requested check the progress on the new Workflow, otherwise reset this Workflow.',
},
BadBinary: {
title: 'Bad Binary',
description:
Expand Down
9 changes: 9 additions & 0 deletions src/lib/models/event-groups/get-event-in-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ describe('eventIsFailureOrTimedOut', () => {
expect(eventIsFailureOrTimedOut(event)).toBe(false);
});

it('should return false if provided an event with workflowTaskFailedEventAttributes and has resetWorkflowFailureInfo', () => {
const event = {
workflowTaskFailedEventAttributes: {
failure: { resetWorkflowFailureInfo: {} },
},
} as unknown as WorkflowEvent;
expect(eventIsFailureOrTimedOut(event)).toBe(false);
});

it('should return true if provided an event with childWorkflowExecutionFailedEventAttributes', () => {
const event = {
childWorkflowExecutionFailedEventAttributes: {},
Expand Down
24 changes: 24 additions & 0 deletions src/lib/utilities/get-workflow-task-failed-event.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import type { EventSortOrder } from '$lib/stores/event-view';
import type { WorkflowTaskFailedEventAttributes } from '$lib/types';
import type {
WorkflowEvent,
WorkflowEvents,
WorkflowTaskCompletedEvent,
WorkflowTaskFailedEvent,
} from '$lib/types/events';
import type { WorkflowTaskFailedCause } from '$lib/types/workflows';

import { toWorkflowTaskFailureReadable } from './screaming-enums';

const isFailedTaskEvent = (
event: WorkflowEvent,
Expand All @@ -18,6 +22,22 @@ const isCompletedTaskEvent = (
return event.eventType === 'WorkflowTaskCompleted';
};

export const getErrorCause = (
error: WorkflowTaskFailedEvent,
): WorkflowTaskFailedCause => {
const {
workflowTaskFailedEventAttributes: { failure, cause },
} = error as WorkflowTaskFailedEvent & {
workflowTaskFailedEventAttributes: WorkflowTaskFailedEventAttributes;
};

if (failure?.applicationFailureInfo?.type === 'workflowTaskHeartbeatError') {
return 'WorkflowTaskHeartbeatError';
}

return toWorkflowTaskFailureReadable(cause);
};

const getFailedWorkflowTask = (
fullEventHistory: WorkflowEvents,
): WorkflowTaskFailedEvent | undefined => {
Expand All @@ -32,6 +52,10 @@ const getFailedWorkflowTask = (
isFailedTaskEvent(event),
) as WorkflowTaskFailedEvent;

const cause = getErrorCause(failedWorkflowTask);

if (cause === 'ResetWorkflow') return;

if (completedWorkflowTaskIndex < 0) return failedWorkflowTask;

// History is sorted in descending order, so index of failed task should be less than index of completed task
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utilities/is-event-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ export const isWorkflowTaskFailedEvent = (event: WorkflowEvent) => {
return (
isPureWorkflowTaskFailedEvent(event) &&
event.workflowTaskFailedEventAttributes?.failure?.message !==
'UnhandledCommand'
'UnhandledCommand' &&
!event.workflowTaskFailedEventAttributes?.failure?.resetWorkflowFailureInfo
);
};

Expand Down
Loading