Skip to content

Conversation

@ameliahsu
Copy link
Contributor

Surfacing test notification errors using the alert builder error context that we already have for form submission errors

Screenshot 2025-12-10 at 12 18 04 PM

@ameliahsu ameliahsu requested a review from a team as a code owner December 10, 2025 20:19
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 10, 2025
Comment on lines 153 to 156
setErrors({
...errors,
...error?.responseJSON?.detail,
});

This comment was marked as outdated.

setErrors({
...errors,
...error?.responseJSON?.detail,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Stale errors closure loses validation errors in catch block

The catch block uses the errors value from the callback closure, but setErrors is called earlier at line 141 which updates the state. If future code changes allow reaching the catch block with non-empty actionErrors, the catch block's setErrors({...errors, ...}) would use the stale errors from the closure rather than the updated state, potentially overwriting the validation errors that were just set.

Fix in Cursor Fix in Web

return stripActionFields(action);
})
);
} catch (error: any) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of catching, the more common usage is to send onError to useSendTestNotification(). The hook can supply the expected error type so you don't need to type any here.

A couple other things: you don't need mutateAsync here, you can just use mutate this way. Oh, and I think we should be using isPending from useSendTestNotification to disable the button while the request is in flight.

@ameliahsu ameliahsu requested a review from malwilley December 11, 2025 13:12
@ameliahsu ameliahsu merged commit 640a756 into master Dec 11, 2025
49 checks passed
@ameliahsu ameliahsu deleted the mia/aci/show-test-notif-errors branch December 11, 2025 18:42
@github-actions github-actions bot locked and limited conversation to collaborators Dec 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants