Quiet expected upgrade-preview 400s in Sentry#1714
Open
j-ruda-guardian wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces Sentry noise by treating Digital Plus upgrade-preview HTTP 400 responses as an expected “ineligible for online upgrade” outcome (returning null) rather than throwing, while still surfacing unexpected failures (e.g., 5xx) as errors.
Changes:
- Updated
fetchUpgradePreviewDatato returnnullfor HTTP 400 (expected ineligibility) and only throw for other non-OK responses. - Adjusted upgrade preview consumers to handle a
nullpreview response (deep-link loader redirects; upgrade preview hook sets an error state for UI).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| client/utilities/productUtils.ts | Returns null for upgrade-preview 400s to avoid throwing/capturing expected ineligibility in Sentry. |
| client/utilities/hooks/useUpgradeProductLoader.ts | Handles null preview by redirecting when deep-linking into the upgrade flow. |
| client/utilities/hooks/useUpgradePreview.ts | Handles null preview response by setting preview error state (used to show the “not eligible” UI). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
client/utilities/productUtils.ts:282
fetchUpgradePreviewDatacan now returnnullfor an expected 400/ineligible response, but the function name still implies it always returns preview data. Consider renaming to make the nullable contract explicit so future call sites don’t forget to handlenull.
export const fetchUpgradePreviewData = async (params: {
subscriptionId: string;
isTestUser: boolean;
}): Promise<UpgradePreviewResponse | null> => {
const response = await changePlanFetch({
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current situation/background
https://the-guardian.sentry.io/issues/7303821377/?environment=theguardian.com&project=1208603&query=is%3Aunresolved&referrer=issue-stream&sort=freq
Treat Digital Plus upgrade-preview 400 responses as expected ineligibility (null) instead of throwing. Keep showing the existing “not eligible” UI, and only report unexpected failures (e.g. 5xx) to Sentry