From 892c5f0947c92ba8c286d0ad56a2cbade22cb305 Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Fri, 15 May 2026 13:16:06 +0000 Subject: [PATCH 1/8] Bug-2003889: Return an appropriate message when lando is still loading Updated the response message in src/logic/treeherder.ts to convey to the user that lando has still not completed the try pushes. --- src/logic/treeherder.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index 45fb9bf45..aca6f50d1 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -85,10 +85,21 @@ export async function fetchRevisionFromHash( async function fetchFromTreeherder(url: string) { const response = await fetch(url); if (!response.ok) { + const errorText = await response.text(); if (response.status === 400) { - throw new Error( - `Error when requesting treeherder: ${await response.text()}`, - ); + try { + const errorJson = JSON.parse(errorText) as Record; + if (errorJson.new_revision?.[0] === 'This field may not be blank.') { + throw new Error( + 'The comparison cannot be performed because the new revision is missing. ' + + 'This typically happens when the "mach try perf" push is still being processed by Lando. ' + + 'Please wait a few moments for the push to complete and then refresh the page.', + ); + } + } catch { + // Fall through to the generic error if the response is not JSON or doesn't have the expected structure + } + throw new Error(`Error when requesting treeherder: ${errorText}`); } else { throw new Error( `Error when requesting treeherder: (${response.status}) ${response.statusText}`, From bf090e99d628f056d1b05bb76132b740bf4b0a7e Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Mon, 18 May 2026 13:27:06 +0000 Subject: [PATCH 2/8] feat: Added unit test Added unit test for the updates --- src/__tests__/App.test.tsx | 29 +++++++++++++++++++++++++++++ src/logic/treeherder.ts | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/__tests__/App.test.tsx b/src/__tests__/App.test.tsx index d0697ce41..55770b23d 100644 --- a/src/__tests__/App.test.tsx +++ b/src/__tests__/App.test.tsx @@ -148,6 +148,35 @@ describe('App', () => { expect(document.body).toMatchSnapshot(); }); + it('Should render the correct error message to the console when new_revision is required but missing', async () => { + // Silence console.error for a better console output. + jest.spyOn(console, 'error').mockImplementation(() => {}); + fetchMock.get( + 'begin:https://treeherder.mozilla.org/api/perfcompare/results/', + { + status: 400, + body: JSON.stringify({ + new_revision: ['This field may not be blank.'], + }), + }, + ); + + await router.navigate( + '/compare-results/?baseRev=spam&baseRepo=mozilla-central&framework=2', + ); + render(); + + await screen.findByText(/Error/); + expect(console.error).toHaveBeenCalledWith( + new Error( + 'The comparison cannot be performed because the `new_revision` field is missing. ' + + 'This typically happens when the `mach try perf` push is still being processed by Lando. ' + + 'Please wait a few moments for the push to complete and then refresh the page.', + ), + ); + expect(document.body).toMatchSnapshot(); + }); + it('Should render an error page for compare over time when the treeherder request fails with an error 400', async () => { // Silence console.error for a better console output. We'll check its result later. jest.spyOn(console, 'error').mockImplementation(() => {}); diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index aca6f50d1..ba05d631a 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -91,8 +91,8 @@ async function fetchFromTreeherder(url: string) { const errorJson = JSON.parse(errorText) as Record; if (errorJson.new_revision?.[0] === 'This field may not be blank.') { throw new Error( - 'The comparison cannot be performed because the new revision is missing. ' + - 'This typically happens when the "mach try perf" push is still being processed by Lando. ' + + 'The comparison cannot be performed because the `new_revision` field is missing. ' + + 'This typically happens when the `mach try perf` push is still being processed by Lando. ' + 'Please wait a few moments for the push to complete and then refresh the page.', ); } From 3577d5e248cfa421301a5e93811375de3675a2be Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Mon, 18 May 2026 13:42:18 +0000 Subject: [PATCH 3/8] fix: Test error message test the error message --- src/logic/treeherder.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index ba05d631a..d2d42f423 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -89,6 +89,7 @@ async function fetchFromTreeherder(url: string) { if (response.status === 400) { try { const errorJson = JSON.parse(errorText) as Record; + throw new Error(`Bad request: ${JSON.stringify(errorJson)}`); if (errorJson.new_revision?.[0] === 'This field may not be blank.') { throw new Error( 'The comparison cannot be performed because the `new_revision` field is missing. ' + From af1f7eb67b03f3ce99b083dc84954283e727e85b Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Mon, 18 May 2026 13:49:52 +0000 Subject: [PATCH 4/8] feat: Adding debug prints Adding debug print --- src/logic/treeherder.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index d2d42f423..8a4120d1a 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -89,7 +89,6 @@ async function fetchFromTreeherder(url: string) { if (response.status === 400) { try { const errorJson = JSON.parse(errorText) as Record; - throw new Error(`Bad request: ${JSON.stringify(errorJson)}`); if (errorJson.new_revision?.[0] === 'This field may not be blank.') { throw new Error( 'The comparison cannot be performed because the `new_revision` field is missing. ' + @@ -100,7 +99,7 @@ async function fetchFromTreeherder(url: string) { } catch { // Fall through to the generic error if the response is not JSON or doesn't have the expected structure } - throw new Error(`Error when requesting treeherder: ${errorText}`); + throw new Error(`Error when requesting treeherder here: ${errorText}`); } else { throw new Error( `Error when requesting treeherder: (${response.status}) ${response.statusText}`, From 7e2a4a9580c51e428d1a89e36fedd64bdfefd319 Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Mon, 18 May 2026 14:07:35 +0000 Subject: [PATCH 5/8] fix: Updating check Updating check --- src/logic/treeherder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index 8a4120d1a..32965741e 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -88,8 +88,8 @@ async function fetchFromTreeherder(url: string) { const errorText = await response.text(); if (response.status === 400) { try { - const errorJson = JSON.parse(errorText) as Record; - if (errorJson.new_revision?.[0] === 'This field may not be blank.') { + const errorJson = JSON.parse(errorText) as Record; + if (errorJson.new_revision?.[0].trim() === 'This field may not be blank.') { throw new Error( 'The comparison cannot be performed because the `new_revision` field is missing. ' + 'This typically happens when the `mach try perf` push is still being processed by Lando. ' + From 431193a08a0ab069802247ec2355c6f4c6b530df Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Mon, 18 May 2026 14:19:32 +0000 Subject: [PATCH 6/8] feat: Log on console Log on console --- src/logic/treeherder.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index 32965741e..5b52aa288 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -89,6 +89,7 @@ async function fetchFromTreeherder(url: string) { if (response.status === 400) { try { const errorJson = JSON.parse(errorText) as Record; + console.log('Error response from Treeherder API:', errorJson); if (errorJson.new_revision?.[0].trim() === 'This field may not be blank.') { throw new Error( 'The comparison cannot be performed because the `new_revision` field is missing. ' + From 0aedef5e14b4132762d312225e620d120c55a169 Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Mon, 18 May 2026 14:22:33 +0000 Subject: [PATCH 7/8] fix: Throw error to log lines Throw error to log lines --- src/logic/treeherder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index 5b52aa288..3437aaabf 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -89,7 +89,7 @@ async function fetchFromTreeherder(url: string) { if (response.status === 400) { try { const errorJson = JSON.parse(errorText) as Record; - console.log('Error response from Treeherder API:', errorJson); + throw new Error('Error response from Treeherder API:', errorJson); if (errorJson.new_revision?.[0].trim() === 'This field may not be blank.') { throw new Error( 'The comparison cannot be performed because the `new_revision` field is missing. ' + From d87dd60d0049a462986ca8cc792137c6ce3bb540 Mon Sep 17 00:00:00 2001 From: Alexander Moses Date: Mon, 18 May 2026 14:29:01 +0000 Subject: [PATCH 8/8] fix: Updating check removed incorret return --- src/logic/treeherder.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/logic/treeherder.ts b/src/logic/treeherder.ts index 3437aaabf..32965741e 100644 --- a/src/logic/treeherder.ts +++ b/src/logic/treeherder.ts @@ -89,7 +89,6 @@ async function fetchFromTreeherder(url: string) { if (response.status === 400) { try { const errorJson = JSON.parse(errorText) as Record; - throw new Error('Error response from Treeherder API:', errorJson); if (errorJson.new_revision?.[0].trim() === 'This field may not be blank.') { throw new Error( 'The comparison cannot be performed because the `new_revision` field is missing. ' +