Skip to content

Commit

Permalink
read real 409 conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Sep 16, 2024
1 parent 74256cd commit 0d9347a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand 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');
Expand Down
15 changes: 8 additions & 7 deletions frontend/src/pages/projects/screens/spawner/SpawnerFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
assembleSecret,
createNotebook,
createSecret,
K8sStatusError,
mergePatchUpdateNotebook,
updateNotebook,
} from '~/api';
Expand Down Expand Up @@ -56,7 +57,7 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
dataConnection,
canEnablePipelines,
}) => {
const [errorMessage, setErrorMessage] = React.useState('');
const [error, setError] = React.useState<K8sStatusError>();

const {
dashboardConfig: {
Expand Down Expand Up @@ -123,17 +124,17 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
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);
};

Expand Down Expand Up @@ -280,15 +281,15 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({

return (
<Stack hasGutter>
{errorMessage && (
{error && (
<StackItem>
<Alert
isInline
variant="danger"
title="Error creating workbench"
actionLinks={
// If this is a 409 conflict error
errorMessage.includes('the object has been modified') ? (
error.statusObject.code === 409 ? (
<>
<AlertActionLink
onClick={() =>
Expand All @@ -308,7 +309,7 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
) : undefined
}
>
{errorMessage}
{error.message}
</Alert>
</StackItem>
)}
Expand Down

0 comments on commit 0d9347a

Please sign in to comment.