Compare commits

...

1 Commits

Author SHA1 Message Date
Sonarly Claude Code 6ce23a4115 fix(twenty-front): return null instead of throwing in SeeVersionWorkflowRunSingleRecordCommand
https://sonarly.com/issue/26767?type=bug

The "See Version" command menu button on the workflowRuns index page throws an unhandled error when the selected record's `workflowVersion` relation data isn't loaded in the record store, causing a snackbar error and Sentry noise.

Fix: Two changes were made:

1. ROOT CAUSE FIX (SeeVersionWorkflowRunSingleRecordCommand.tsx):
   Changed `throw new Error('Selected record is required to see version workflow run')` to `return null`.

   Why: On the /objects/workflowRuns index page, record index queries use shallow depth and don't load nested relation objects like `workflowVersion: { id: ... }`. When a user selects a workflowRun row, this pinned command mounts immediately via CommandRunner and tries to access `selectedRecord.workflowVersion.id`, which is undefined. The throw crashes the component, triggers the error boundary, shows an error snackbar, and fires a Sentry event.

   Returning null instead is the correct pattern — the sibling SeeWorkflowWorkflowRunSingleRecordCommand handles the same scenario with `return null`. The error boundary renders a null fallback anyway, so the throw provides no benefit over returning null directly. The command simply becomes a no-op when relation data isn't available.

2. MONITORING IMPROVEMENT (CommandMenuItemErrorBoundary.tsx):
   Enhanced the Sentry capture to:
   - Add `commandMenuItemId` tag for easier filtering/debugging
   - Set severity level to `warning` instead of default `error` — command menu errors are recoverable (the boundary renders null), not fatal
   - Add fingerprint `['command-menu-item-error', error.message]` so Sentry groups events by message rather than creating duplicate issues per stack trace variation

   This reduces Sentry noise from expected edge cases that reach the error boundary.
2026-04-15 19:49:42 +00:00
2 changed files with 7 additions and 1 deletions
@@ -29,6 +29,12 @@ export const CommandMenuItemErrorBoundary = ({
const { captureException } = await import('@sentry/react');
captureException(error, (scope) => {
scope.setTag('component', 'CommandMenuItem');
scope.setTag('commandMenuItemId', commandMenuItemId);
scope.setLevel('warning');
scope.setFingerprint([
'command-menu-item-error',
error.message,
]);
return scope;
});
@@ -11,7 +11,7 @@ export const SeeVersionWorkflowRunSingleRecordCommand = () => {
!isDefined(selectedRecord) ||
!isDefined(selectedRecord?.workflowVersion?.id)
) {
throw new Error('Selected record is required to see version workflow run');
return null;
}
return (