Skip to content

Quiet expected upgrade-preview 400s in Sentry#1714

Open
j-ruda-guardian wants to merge 5 commits into
mainfrom
jr/fix-400-preview-endpoint-errors
Open

Quiet expected upgrade-preview 400s in Sentry#1714
j-ruda-guardian wants to merge 5 commits into
mainfrom
jr/fix-400-preview-endpoint-errors

Conversation

@j-ruda-guardian

Copy link
Copy Markdown
Contributor

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

@j-ruda-guardian
j-ruda-guardian requested a review from Copilot July 21, 2026 11:55
@j-ruda-guardian j-ruda-guardian added the maintenance Departmental tracking: maintenance work, not a fix or a feature label Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 fetchUpgradePreviewData to return null for HTTP 400 (expected ineligibility) and only throw for other non-OK responses.
  • Adjusted upgrade preview consumers to handle a null preview 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.

Comment thread client/utilities/hooks/useUpgradePreview.ts Outdated
Comment thread client/utilities/hooks/useUpgradeProductLoader.ts Outdated
Comment thread client/utilities/productUtils.ts
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

  • fetchUpgradePreviewData can now return null for 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 handle null.
export const fetchUpgradePreviewData = async (params: {
	subscriptionId: string;
	isTestUser: boolean;
}): Promise<UpgradePreviewResponse | null> => {
	const response = await changePlanFetch({

Comment thread client/utilities/hooks/useUpgradeProductLoader.ts
Comment thread client/utilities/hooks/useUpgradeProductLoader.ts
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

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

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants