Skip to content

Commit 3c4d261

Browse files
Gumichocopengin8B-Step62
authored andcommitted
fix: show not found page if prompt name does not exist (mlflow#14981)
Signed-off-by: Keita Nonaka <[email protected]> Signed-off-by: Yuki Watanabe <[email protected]> Co-authored-by: Yuki Watanabe <[email protected]>
1 parent c10912f commit 3c4d261

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Diff for: mlflow/server/js/src/experiment-tracking/pages/prompts/PromptsDetailsPage.test.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ describe('PromptsDetailsPage', () => {
191191
expect(screen.getByRole('columnheader', { name: 'Registered at' })).toBeInTheDocument();
192192
});
193193

194-
it('should display error boundary UI component upon showstopper failure', async () => {
194+
it('should display 404 UI component upon showstopper failure', async () => {
195195
jest.spyOn(console, 'error').mockImplementation(() => {});
196196
server.use(getFailedRegisteredPromptDetailsResponse(404));
197197

198198
renderTestComponent();
199-
await waitFor(() => {
200-
expect(screen.getByRole('heading', { name: 'Error' })).toBeInTheDocument();
201-
});
202-
expect(screen.getByText('The requested resource was not found.')).toBeInTheDocument();
199+
expect(await screen.findByRole('heading', { name: 'Page Not Found' })).toBeInTheDocument();
200+
expect(
201+
await screen.findByRole('heading', { name: "Prompt name 'prompt1' does not exist, go back to the home page." }),
202+
).toBeInTheDocument();
203203
jest.restoreAllMocks();
204204
});
205205
});

Diff for: mlflow/server/js/src/experiment-tracking/pages/prompts/PromptsDetailsPage.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import ErrorUtils from '../../../common/utils/ErrorUtils';
3434
import { PromptPageErrorHandler } from './components/PromptPageErrorHandler';
3535
import { first, isEmpty } from 'lodash';
3636
import { PromptsListTableTagsBox } from './components/PromptDetailsTagsBox';
37+
import { PromptNotFoundView } from './components/PromptNotFoundView';
3738
import { useUpdatePromptVersionMetadataModal } from './hooks/useUpdatePromptVersionMetadataModal';
3839

3940
const getAliasesModalTitle = (version: string) => (
@@ -123,9 +124,9 @@ const PromptsDetailsPage = () => {
123124
),
124125
});
125126

126-
// If the load error occurs, throw the error into the error boundary
127+
// If the load error occurs, show not found page
127128
if (promptLoadError) {
128-
throw promptLoadError;
129+
return <PromptNotFoundView promptName={promptName} />;
129130
}
130131

131132
const breadcrumbs = (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ErrorView } from '@mlflow/mlflow/src/common/components/ErrorView';
2+
import Routes from '../../../routes';
3+
4+
interface Props {
5+
promptName: string;
6+
}
7+
8+
export function PromptNotFoundView({ promptName }: Props) {
9+
return (
10+
<ErrorView
11+
statusCode={404}
12+
subMessage={`Prompt name '${promptName}' does not exist`}
13+
fallbackHomePageReactRoute={Routes.promptsPageRoute}
14+
/>
15+
);
16+
}

0 commit comments

Comments
 (0)