Skip to content

Allow json in workflow run's error field #12762

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

Merged
merged 5 commits into from
Jun 20, 2025

Conversation

Devessier
Copy link
Contributor

@Devessier Devessier commented Jun 20, 2025

We can now inspect errors even if they contain complex data as objects. Only the first line of the error is put in red.

CleanShot 2025-06-20 at 18 31 54@2x

image

Copy link
Contributor

github-actions bot commented Jun 20, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:48743

This environment will automatically shut down when the PR is closed or after 5 hours.

@Devessier Devessier marked this pull request as ready for review June 20, 2025 16:37
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Enhanced workflow error visualization by allowing JSON objects in error fields, enabling detailed error inspection while maintaining UI clarity.

  • Modified packages/twenty-front/src/modules/workflow/validation-schemas/workflowSchema.ts to accept JSON objects in error fields instead of just strings
  • Added red highlighting variant in packages/twenty-ui/src/json-visualizer components to visually distinguish error content
  • Updated packages/twenty-front/src/modules/workflow/hooks/useWorkflowRun.ts to properly handle validation failures with detailed error objects
  • Improved WorkflowRunStepOutputDetail component to only highlight the error key in red, keeping other output data readable
  • Enhanced error visualization in JsonTree component with support for nested object highlighting

6 files reviewed, 4 comments
Edit PR Review Bot Settings | Greptile

@@ -6,16 +6,20 @@ import { useJsonTreeContextOrThrow } from '@ui/json-visualizer/hooks/useJsonTree
import { ANIMATION } from '@ui/theme';
import { motion } from 'framer-motion';

const StyledButton = styled(motion.button)`
const StyledButton = styled(motion.button)<{ variant?: 'blue' | 'red' }>`
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using union type definition instead of inline type. Extract ArrowVariant = 'blue' | 'red' to types.

color: ${({ theme }) => theme.font.color.tertiary};
const StyledElementsCount = styled.span<{ variant?: 'red' }>`
color: ${({ theme, variant }) =>
variant === 'red' ? theme.font.color.danger : theme.font.color.tertiary};
`;

const StyledJsonList = styled(JsonList)``.withComponent(motion.ul);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: StyledJsonList using withComponent after styled definition is an unusual pattern. Consider using styled(motion.ul) directly

Comment on lines +24 to 26
if (!isDefined(rawRecord)) {
return undefined;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This check should come before the schema validation on line 22 to prevent unnecessary validation of undefined records.

Suggested change
if (!isDefined(rawRecord)) {
return undefined;
}
const { record: rawRecord } = useFindOneRecord({
objectNameSingular: CoreObjectNameSingular.WorkflowRun,
objectRecordId: workflowRunId,
});
if (!isDefined(rawRecord)) {
return undefined;
}
const {
success,
data: record,
error,
} = useMemo(() => workflowRunSchema.safeParse(rawRecord), [rawRecord]);

Comment on lines +70 to +76
const setRedHighlightingForEveryNode: GetJsonNodeHighlighting = (keyPath) => {
if (keyPath === 'error') {
return 'red';
}

return undefined;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider extracting setRedHighlightingForEveryNode to a utility function since it's a pure function that could be reused across components

@Devessier Devessier merged commit 22e1268 into main Jun 20, 2025
55 of 58 checks passed
@Devessier Devessier deleted the allow-json-in-error-workflow-run branch June 20, 2025 17:07
Copy link

sentry-io bot commented Jun 26, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ [**ZodError: ** in prod

  • ‼️ [**ZodError: ** in prod

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants