From 0d9347a0f88fd9173a7ace5cd4f1ba8f06865807 Mon Sep 17 00:00:00 2001 From: Juntao Wang Date: Fri, 6 Sep 2024 17:29:46 -0400 Subject: [PATCH] read real 409 conflict --- .../cypress/tests/mocked/projects/workbench.cy.ts | 3 +-- .../projects/screens/spawner/SpawnerFooter.tsx | 15 ++++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts index 3ff471737f..aa0ac6d97e 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/mocked/projects/workbench.cy.ts @@ -555,6 +555,7 @@ describe('Workbench page', () => { editSpawnerPage.k8sNameDescription.findDisplayNameInput().fill('Updated Notebook'); cy.interceptK8s('PUT', NotebookModel, mockNotebookK8sResource({})).as('editWorkbenchDryRun'); + cy.interceptK8s('PATCH', NotebookModel, mockNotebookK8sResource({})).as('editWorkbench'); editSpawnerPage.findSubmitButton().click(); cy.wait('@editWorkbenchDryRun').then((interception) => { expect(interception.request.url).to.include('?dryRun=All'); @@ -578,8 +579,6 @@ describe('Workbench page', () => { }, }); }); - - cy.interceptK8s('PATCH', NotebookModel, mockNotebookK8sResource({})).as('editWorkbench'); // Actual request cy.wait('@editWorkbench').then((interception) => { expect(interception.request.url).not.to.include('?dryRun=All'); diff --git a/frontend/src/pages/projects/screens/spawner/SpawnerFooter.tsx b/frontend/src/pages/projects/screens/spawner/SpawnerFooter.tsx index e121f10435..e688d4cffb 100644 --- a/frontend/src/pages/projects/screens/spawner/SpawnerFooter.tsx +++ b/frontend/src/pages/projects/screens/spawner/SpawnerFooter.tsx @@ -13,6 +13,7 @@ import { assembleSecret, createNotebook, createSecret, + K8sStatusError, mergePatchUpdateNotebook, updateNotebook, } from '~/api'; @@ -56,7 +57,7 @@ const SpawnerFooter: React.FC = ({ dataConnection, canEnablePipelines, }) => { - const [errorMessage, setErrorMessage] = React.useState(''); + const [error, setError] = React.useState(); const { dashboardConfig: { @@ -123,17 +124,17 @@ const SpawnerFooter: React.FC = ({ refreshAllProjectData(); navigate(`/projects/${projectName}?section=${ProjectSectionID.WORKBENCHES}`); }; - const handleError = (e: Error) => { + const handleError = (e: K8sStatusError) => { fireFormTrackingEvent('Workbench Created', { outcome: TrackingOutcome.submit, success: false, error: e.message, }); - setErrorMessage(e.message || 'Error creating workbench'); + setError(e); setCreateInProgress(false); }; const handleStart = () => { - setErrorMessage(''); + setError(undefined); setCreateInProgress(true); }; @@ -280,7 +281,7 @@ const SpawnerFooter: React.FC = ({ return ( - {errorMessage && ( + {error && ( = ({ title="Error creating workbench" actionLinks={ // If this is a 409 conflict error - errorMessage.includes('the object has been modified') ? ( + error.statusObject.code === 409 ? ( <> @@ -308,7 +309,7 @@ const SpawnerFooter: React.FC = ({ ) : undefined } > - {errorMessage} + {error.message} )}