Skip to content

Commit

Permalink
DT-2499 - wf reset ux improvement (#2359)
Browse files Browse the repository at this point in the history
* don't show workflow error for ResetWorkflow type errors

don't highlight workflow task failure error in event history table if ResetWorkflow error

* remove unused typed error component

* fix logic, add test

* better check for reset

* rm console.log
  • Loading branch information
rossedfort authored Sep 30, 2024
1 parent a1d2cff commit fcc8279
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 108 deletions.
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'}
<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

0 comments on commit fcc8279

Please sign in to comment.