Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard] invalid dashboard displayed as 404 instead of showing validation error #211659

Open
nreese opened this issue Feb 18, 2025 · 1 comment · May be fixed by #211661
Open

[dashboard] invalid dashboard displayed as 404 instead of showing validation error #211659

nreese opened this issue Feb 18, 2025 · 1 comment · May be fixed by #211661
Labels
bug Fixes for quality problems that affect the customer experience Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas

Comments

@nreese
Copy link
Contributor

nreese commented Feb 18, 2025

When loading a dashboard, any contentManagementService.client.get error is converted into a SavedObjectNotFound error. This results in 404 error message when that is not always the case. The dashboard may exist, and instead, the end point failed for another reason, like maybe the content management schema validation failed.

https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/dashboard/public/services/dashboard_content_management_service/lib/load_dashboard_state.ts#L87

const result = await contentManagementService.client
      .get<DashboardGetIn, DashboardGetOut>({
        contentTypeId: DASHBOARD_CONTENT_ID,
        id,
      })
      .catch((e) => {
        throw new SavedObjectNotFound(DASHBOARD_CONTENT_ID, id);
      });

Instead, only 404 errors should get converted to SavedObjectNotFound. The logic should be cleaned up like such

import { isHttpFetchError } from '@kbn/core-http-browser';
const result = await contentManagementService.client
      .get<DashboardGetIn, DashboardGetOut>({
        contentTypeId: DASHBOARD_CONTENT_ID,
        id,
      })
      .catch((e) => {
        if (isHttpFetchError(e) && e.response?.status === 404) {
          throw new SavedObjectNotFound(DASHBOARD_CONTENT_ID, id);
        }
        throw e;
      });

The problem is that DashboardRenderer only renders the text of the error as unformatted text. This should probably be clean-up and display something better. Maybe design needs to get involved.
https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/dashboard/public/dashboard_container/external_api/dashboard_renderer.tsx#L107

if (error) {
      return error instanceof SavedObjectNotFound ? (
        <Dashboard404Page dashboardRedirect={dashboardRedirect} />
      ) : (
        error.message
      );
    }
@nreese nreese added bug Fixes for quality problems that affect the customer experience Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas labels Feb 18, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants