OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

[Multiple Datasource] Add API Call Error Handling: Simulate Network Error and 404 Response

Open yujin-emma opened this issue 9 months ago • 1 comments

Is your feature request related to a problem? Please describe.

export async function getDataSourceById(
  id: string,
  savedObjectsClient: SavedObjectsClientContract
) {
  const response = await savedObjectsClient.get('data-source', id);

  if (!response || response.error) {
    throw new Error('Unable to find data source');
  }

  const attributes: any = response?.attributes || {};
  return {
    id: response.id,
    title: attributes.title,
    endpoint: attributes.endpoint,
    description: attributes.description || '',
    auth: attributes.auth,
  };
}

This function only return generic error, and the usage of this function not handle the network error, we need to add the handling for this part

Describe the solution you'd like

Use OsdError instead of Error Add test for non-OsdError to mock network issue Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

yujin-emma avatar May 07 '24 21:05 yujin-emma

https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data_source_management/public/components/utils.ts#L153

yujin-emma avatar May 07 '24 21:05 yujin-emma

Hi @yujin-emma, are we targeting to address this in 2.15 or 2.16?

BionIT avatar Jun 03 '24 21:06 BionIT