Skip to content

Commit

Permalink
Uses healper function to validate response
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers committed Aug 16, 2021
1 parent 05b91ae commit bb1dfa2
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
*/

import * as esKuery from '@kbn/es-query';
import { isSupportedEsServer } from '../../../elasticsearch';
import { LegacyUrlAlias, LEGACY_URL_ALIAS_TYPE } from '../../object_types';
import type { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
import type { SavedObjectsSerializer } from '../../serialization';
import type { SavedObject, SavedObjectsBaseOptions } from '../../types';
import { SavedObjectsErrorHelpers } from './errors';
import { getRootFields } from './included_fields';
import { getSavedObjectFromSource, rawDocExistsInNamespace } from './internal_utils';
import {
getSavedObjectFromSource,
rawDocExistsInNamespace,
isNotFoundFromUnsupportedServer,
} from './internal_utils';
import type {
ISavedObjectsPointInTimeFinder,
SavedObjectsCreatePointInTimeFinderOptions,
Expand Down Expand Up @@ -200,7 +203,12 @@ async function getObjectsAndReferences({
{ ignore: [404] }
);
// exit early if we can't verify a 404 response is from Elasticsearch
if (bulkGetResponse.statusCode === 404 && !isSupportedEsServer(bulkGetResponse.headers)) {
if (
isNotFoundFromUnsupportedServer({
statusCode: bulkGetResponse.statusCode,
headers: bulkGetResponse.headers,
})
) {
throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError();
}
const newObjectsToGet = new Set<string>();
Expand Down

0 comments on commit bb1dfa2

Please sign in to comment.