Allow json in workflow run's error field (#12762)
We can now inspect errors even if they contain complex data as objects. Only the first line of the error is put in red.  
This commit is contained in:
committed by
GitHub
parent
1e0ee9421d
commit
22e126869c
@ -3,6 +3,7 @@ import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
|
||||
import { WorkflowRun } from '@/workflow/types/Workflow';
|
||||
import { workflowRunSchema } from '@/workflow/validation-schemas/workflowSchema';
|
||||
import { useMemo } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useWorkflowRun = ({
|
||||
workflowRunId,
|
||||
@ -14,13 +15,18 @@ export const useWorkflowRun = ({
|
||||
objectRecordId: workflowRunId,
|
||||
});
|
||||
|
||||
const { success, data: record } = useMemo(
|
||||
() => workflowRunSchema.safeParse(rawRecord),
|
||||
[rawRecord],
|
||||
);
|
||||
const {
|
||||
success,
|
||||
data: record,
|
||||
error,
|
||||
} = useMemo(() => workflowRunSchema.safeParse(rawRecord), [rawRecord]);
|
||||
|
||||
if (!isDefined(rawRecord)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
return undefined;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return record;
|
||||
|
||||
@ -271,7 +271,7 @@ export const workflowTriggerSchema = z.discriminatedUnion('type', [
|
||||
// Step output schemas
|
||||
export const workflowExecutorOutputSchema = z.object({
|
||||
result: z.any().optional(),
|
||||
error: z.string().optional(),
|
||||
error: z.any().optional(),
|
||||
pendingEvent: z.boolean().optional(),
|
||||
});
|
||||
|
||||
@ -286,7 +286,7 @@ export const workflowRunOutputSchema = z.object({
|
||||
steps: z.array(workflowActionSchema),
|
||||
}),
|
||||
stepsOutput: workflowRunOutputStepsOutputSchema.optional(),
|
||||
error: z.string().optional(),
|
||||
error: z.any().optional(),
|
||||
});
|
||||
|
||||
export const workflowRunContextSchema = z.record(z.any());
|
||||
|
||||
@ -67,7 +67,13 @@ export const WorkflowRunStepOutputDetail = ({ stepId }: { stepId: string }) => {
|
||||
? getTriggerHeaderType(stepDefinition.definition)
|
||||
: i18n._(getActionHeaderTypeOrThrow(stepDefinition.definition.type));
|
||||
|
||||
const setRedHighlightingForEveryNode: GetJsonNodeHighlighting = () => 'red';
|
||||
const setRedHighlightingForEveryNode: GetJsonNodeHighlighting = (keyPath) => {
|
||||
if (keyPath === 'error') {
|
||||
return 'red';
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user