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

Update ES client to 8.1.0-canary.2 #119791

Merged
merged 75 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
6c197fc
upgrade es client to canary 37
Nov 28, 2021
072392c
fix error in core
Nov 28, 2021
8c0c445
mute error in test/
Nov 28, 2021
04a49aa
mute incompatible errors
Nov 28, 2021
808b5c9
unskip request_entity_too_large_exception test
Nov 28, 2021
0b13e50
commit autofix
Nov 28, 2021
e286b8d
unskip batch_size_bytes_exceeds_es_content_length test
Nov 29, 2021
bfebd9e
Merge branch 'main' into issue-119454-es-upgrade
Dec 14, 2021
227f901
fix errors in Core code
Dec 14, 2021
96cde79
fix or mute errors in data plugin
Dec 14, 2021
95528fd
fix data_view_management
Dec 14, 2021
64588f3
fix error index_management
Dec 14, 2021
95ef2c9
fix x-pack/test errors
Dec 14, 2021
de5c389
fix watcher
Dec 14, 2021
1ad0c55
fix event_log
Dec 14, 2021
e7e8cae
fix data_enhanced
Dec 14, 2021
5d1823b
fix uptime
Dec 14, 2021
c6825bd
fix triggers_actions_ui
Dec 14, 2021
2d4a432
fix transform
Dec 14, 2021
1b43084
fix reporting
Dec 14, 2021
ceb7ee8
fix rule_registry
Dec 14, 2021
282d8d5
fix timeline
Dec 14, 2021
ec2dc58
fix task_manager
Dec 14, 2021
e7ebd9e
fix security_solution
Dec 14, 2021
33067db
fix rule_registry
Dec 14, 2021
5bd9bd7
fix fleet
Dec 14, 2021
634106d
fix index_management
Dec 14, 2021
ca3a489
fix lens
Dec 14, 2021
5fe3d64
fix maps
Dec 14, 2021
43d0082
fix ml
Dec 14, 2021
34bfbbf
fix observability
Dec 14, 2021
12594b3
bump to canary 8.1-2
Dec 17, 2021
8cd6567
fix error in packages
Dec 17, 2021
078d6fc
fix errors in core
Dec 17, 2021
cf23498
fix errors in data
Dec 17, 2021
549027f
fix errors in discover
Dec 17, 2021
c734c15
fix some discover tests
Dec 17, 2021
2c4629a
fix errors in telemetry
Dec 17, 2021
eabcdff
fix alerting
Dec 17, 2021
515344b
fix errors in apm
Dec 17, 2021
2da5e47
fix errors in event_log
Dec 17, 2021
96da44a
fix errors in fleet
Dec 17, 2021
3023cc1
fix errors in infra
Dec 17, 2021
690f30e
fix errors in lists
Dec 17, 2021
a0e09cf
mute errors in maps
Dec 17, 2021
9c4e857
fix errors in ml
Dec 17, 2021
ed7efeb
fix errors in osquery
Dec 17, 2021
2176dcf
fix errors in security_solution
Dec 17, 2021
93cecbf
fix errors in stack_alerts
Dec 17, 2021
33cb1ea
fix errors in task_manager
Dec 17, 2021
ad010da
fix errors in timelines
Dec 17, 2021
f70f4a7
fix errors in transform
Dec 17, 2021
e42334c
fix errors in watcher
Dec 17, 2021
7bed4bc
fix errors in tests
Dec 17, 2021
a03d9cb
Merge branch 'main' into issue-119454-es-upgrade
Dec 17, 2021
c0b836f
update docs
Dec 17, 2021
1b5102e
adjust fleet code
Dec 17, 2021
0b1a0d5
fix problem in fleet
Dec 17, 2021
221ebbe
remove outdated _type from data plugin tests
Dec 17, 2021
87a4744
fix packages tests
Dec 17, 2021
44d148f
update type
Dec 17, 2021
b5a9a75
fix tests part 2
Dec 17, 2021
af6f006
Adds product header back to elasticsearch
TinaHeiligers Dec 17, 2021
f8d4b8b
Updates API docs
TinaHeiligers Dec 17, 2021
40551fd
Fix Discover tests
kertal Dec 21, 2021
182b967
Merge branch 'main' into issue-119454-es-upgrade
mshustov Dec 21, 2021
282d3ac
update alerting typings
mshustov Dec 21, 2021
d50c2e9
Fix type errors
dgieselaar Dec 22, 2021
31cdf17
Import Sort type
dgieselaar Dec 22, 2021
06a3f5b
Merge branch 'main' into issue-119454-es-upgrade
kibanamachine Dec 22, 2021
1eb5bfd
Update x-pack/plugins/security_solution/common/endpoint/data_loaders/…
afharo Dec 22, 2021
cfdd8b3
Remove double negation
afharo Dec 22, 2021
ae5ad9f
Merge branch 'main' of github.com:elastic/kibana into issue-119454-es…
afharo Dec 22, 2021
a3b4059
Fix snapshot conflict issues after merge from "main"
afharo Dec 23, 2021
53658ec
Merge branch 'main' into issue-119454-es-upgrade
kibanamachine Dec 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface SavedObjectsFindOptions
| [searchAfter?](./kibana-plugin-core-public.savedobjectsfindoptions.searchafter.md) | estypes.Id\[\] | <i>(Optional)</i> Use the sort values from the previous page to retrieve the next page of results. |
| [searchFields?](./kibana-plugin-core-public.savedobjectsfindoptions.searchfields.md) | string\[\] | <i>(Optional)</i> The fields to perform the parsed query against. See Elasticsearch Simple Query String <code>fields</code> argument for more information |
| [sortField?](./kibana-plugin-core-public.savedobjectsfindoptions.sortfield.md) | string | <i>(Optional)</i> |
| [sortOrder?](./kibana-plugin-core-public.savedobjectsfindoptions.sortorder.md) | estypes.SearchSortOrder | <i>(Optional)</i> |
| [sortOrder?](./kibana-plugin-core-public.savedobjectsfindoptions.sortorder.md) | estypes.SortOrder | <i>(Optional)</i> |
| [type](./kibana-plugin-core-public.savedobjectsfindoptions.type.md) | string \| string\[\] | |
| [typeToNamespacesMap?](./kibana-plugin-core-public.savedobjectsfindoptions.typetonamespacesmap.md) | Map&lt;string, string\[\] \| undefined&gt; | <i>(Optional)</i> This map defines each type to search for, and the namespace(s) to search for the type in; this is only intended to be used by a saved object client wrapper. If this is defined, it supersedes the <code>type</code> and <code>namespaces</code> fields when building the Elasticsearch query. Any types that are not included in this map will be excluded entirely. If a type is included but its value is undefined, the operation will search for that type in the Default namespace. |

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
sortOrder?: estypes.SearchSortOrder;
sortOrder?: estypes.SortOrder;
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface SavedObjectsFindOptions
| [searchAfter?](./kibana-plugin-core-server.savedobjectsfindoptions.searchafter.md) | estypes.Id\[\] | <i>(Optional)</i> Use the sort values from the previous page to retrieve the next page of results. |
| [searchFields?](./kibana-plugin-core-server.savedobjectsfindoptions.searchfields.md) | string\[\] | <i>(Optional)</i> The fields to perform the parsed query against. See Elasticsearch Simple Query String <code>fields</code> argument for more information |
| [sortField?](./kibana-plugin-core-server.savedobjectsfindoptions.sortfield.md) | string | <i>(Optional)</i> |
| [sortOrder?](./kibana-plugin-core-server.savedobjectsfindoptions.sortorder.md) | estypes.SearchSortOrder | <i>(Optional)</i> |
| [sortOrder?](./kibana-plugin-core-server.savedobjectsfindoptions.sortorder.md) | estypes.SortOrder | <i>(Optional)</i> |
| [type](./kibana-plugin-core-server.savedobjectsfindoptions.type.md) | string \| string\[\] | |
| [typeToNamespacesMap?](./kibana-plugin-core-server.savedobjectsfindoptions.typetonamespacesmap.md) | Map&lt;string, string\[\] \| undefined&gt; | <i>(Optional)</i> This map defines each type to search for, and the namespace(s) to search for the type in; this is only intended to be used by a saved object client wrapper. If this is defined, it supersedes the <code>type</code> and <code>namespaces</code> fields when building the Elasticsearch query. Any types that are not included in this map will be excluded entirely. If a type is included but its value is undefined, the operation will search for that type in the Default namespace. |

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
sortOrder?: estypes.SearchSortOrder;
sortOrder?: estypes.SortOrder;
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/charts": "40.1.0",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.35",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.1.0-canary.2",
"@elastic/ems-client": "8.0.0",
"@elastic/eui": "41.2.3",
"@elastic/filesaver": "1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export function createGenerateDocRecordsStream({
// when it is loaded it can skip migration, if possible
index:
hit._index.startsWith('.kibana') && !keepIndexNames ? '.kibana_1' : hit._index,
type: hit._type,
id: hit._id,
source: hit._source,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export const isValidFeatureId = (a: unknown): a is ValidFeatureId =>
* Ref: https://github.com/elastic/elasticsearch/issues/28806#issuecomment-369303620
*
* return stringified Long.MAX_VALUE if we receive Number.MAX_SAFE_INTEGER
* @param sortIds estypes.SearchSortResults | undefined
* @param sortIds estypes.SortResults | undefined
* @returns SortResults
*/
export const getSafeSortIds = (sortIds: estypes.SearchSortResults | null | undefined) => {
export const getSafeSortIds = (sortIds: estypes.SortResults | null | undefined) => {
if (sortIds == null) {
return sortIds;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ export interface SavedObjectsFindOptions {
// (undocumented)
sortField?: string;
// (undocumented)
sortOrder?: estypes.SearchSortOrder;
sortOrder?: estypes.SortOrder;
// (undocumented)
type: string | string[];
typeToNamespacesMap?: Map<string, string[] | undefined>;
Expand Down
26 changes: 18 additions & 8 deletions src/core/server/core_usage_data/core_usage_data_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { hasConfigPathIntersection, ChangedDeprecatedPaths } from '@kbn/config';

import { CoreService } from 'src/core/types';
import { Logger, SavedObjectsServiceStart, SavedObjectTypeRegistry } from 'src/core/server';
import {
AggregationsFiltersAggregate,
AggregationsFiltersBucketItem,
import type {
AggregationsMultiBucketAggregateBase,
AggregationsSingleBucketAggregateBase,
SearchTotalHits,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { CoreContext } from '../core_context';
Expand Down Expand Up @@ -75,6 +75,13 @@ const kibanaOrTaskManagerIndex = (index: string, kibanaConfigIndex: string) => {
return index === kibanaConfigIndex ? '.kibana' : '.kibana_task_manager';
};

interface UsageDataAggs extends AggregationsMultiBucketAggregateBase {
buckets: {
disabled: AggregationsSingleBucketAggregateBase;
active: AggregationsSingleBucketAggregateBase;
};
}

export class CoreUsageDataService
implements CoreService<InternalCoreUsageDataSetup, CoreUsageDataStart>
{
Expand Down Expand Up @@ -153,7 +160,10 @@ export class CoreUsageDataService
private async getSavedObjectAliasUsageData(elasticsearch: ElasticsearchServiceStart) {
// Note: this agg can be changed to use `savedObjectsRepository.find` in the future after `filters` is supported.
// See src/core/server/saved_objects/service/lib/aggregations/aggs_types/bucket_aggs.ts for supported aggregations.
const { body: resp } = await elasticsearch.client.asInternalUser.search({
const { body: resp } = await elasticsearch.client.asInternalUser.search<
unknown,
{ aliases: UsageDataAggs }
>({
index: kibanaIndex,
body: {
track_total_hits: true,
Expand All @@ -179,10 +189,10 @@ export class CoreUsageDataService

const { hits, aggregations } = resp;
const totalCount = (hits.total as SearchTotalHits).value;
const aggregate = aggregations!.aliases as AggregationsFiltersAggregate;
const buckets = aggregate.buckets as Record<string, AggregationsFiltersBucketItem>;
const disabledCount = buckets.disabled.doc_count as number;
const activeCount = buckets.active.doc_count as number;
const aggregate = aggregations!.aliases;
const buckets = aggregate.buckets;
const disabledCount = buckets.disabled.doc_count;
const activeCount = buckets.active.doc_count;
const inactiveCount = totalCount - disabledCount - activeCount;

return { totalCount, disabledCount, activeCount, inactiveCount };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ describe('migration actions', () => {
// Allocate 1 replica so that this index stays yellow
number_of_replicas: '1',
// Disable all shard allocation so that the index status is red
'index.routing.allocation.enable': 'none',
index: { routing: { allocation: { enable: 'none' } } },
},
},
})
Expand Down Expand Up @@ -395,7 +395,7 @@ describe('migration actions', () => {
// Allocate 1 replica so that this index stays yellow
number_of_replicas: '1',
// Disable all shard allocation so that the index status is red
'index.routing.allocation.enable': 'none',
index: { routing: { allocation: { enable: 'none' } } },
},
},
})
Expand Down Expand Up @@ -1450,7 +1450,7 @@ describe('migration actions', () => {
// Allocate 1 replica so that this index stays yellow
number_of_replicas: '1',
// Disable all shard allocation so that the index status is red
'index.routing.allocation.enable': 'none',
index: { routing: { allocation: { enable: 'none' } } },
},
},
},
Expand Down Expand Up @@ -1567,8 +1567,8 @@ describe('migration actions', () => {
}
`);
});
// TODO: unskip after https://github.com/elastic/kibana/issues/116111
it.skip('resolves left request_entity_too_large_exception when the payload is too large', async () => {

it('resolves left request_entity_too_large_exception when the payload is too large', async () => {
const newDocs = new Array(10000).fill({
_source: {
title:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ describe('migration v2', () => {
{ index: '.kibana_7.13.0_001' },
{ meta: true }
);
const settings = response['.kibana_7.13.0_001']
.settings as estypes.IndicesIndexStatePrefixedSettings;
const settings = response['.kibana_7.13.0_001'].settings as estypes.IndicesIndexSettings;
expect(settings.index).not.toBeUndefined();
expect(settings.index!.blocks?.write).not.toEqual('true');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ async function removeLogFile() {
await fs.unlink(logFilePath).catch(() => void 0);
}

// un-skip after https://github.com/elastic/kibana/issues/116111
describe.skip('migration v2', () => {
describe('migration v2', () => {
let esServer: kbnTestServer.TestElasticsearchUtils;
let root: Root;
let startES: () => Promise<kbnTestServer.TestElasticsearchUtils>;
Expand Down Expand Up @@ -111,7 +110,7 @@ function createRoot(options: { maxBatchSizeBytes?: number }) {
},
},
{
oss: true,
oss: false,
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import type { MgetHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { MgetResponseItem } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import {
CORE_USAGE_STATS_ID,
Expand Down Expand Up @@ -150,7 +150,7 @@ export async function internalBulkResolve<T>(
return either.value;
}
const exactMatchDoc = bulkGetResponse?.body.docs[getResponseIndex++];
let aliasMatchDoc: MgetHit<SavedObjectsRawDocSource> | undefined;
let aliasMatchDoc: MgetResponseItem<SavedObjectsRawDocSource> | undefined;
const aliasTargetId = aliasTargetIds[aliasTargetIndex++];
if (aliasTargetId !== undefined) {
aliasMatchDoc = bulkGetResponse?.body.docs[getResponseIndex++];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { LegacyUrlAlias, LEGACY_URL_ALIAS_TYPE } from '../../object_types';
import type { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
import type {
Expand Down Expand Up @@ -79,6 +79,10 @@ interface ParsedObject {
spaces: Set<string>;
}

function isMgetDoc(doc?: estypes.MgetResponseItem<unknown>): doc is estypes.GetGetResult {
return Boolean(doc && 'found' in doc);
}

/**
* Conducts pre-flight checks before object creation. Consumers should only check eligible objects (multi-namespace types).
* For each object that the consumer intends to create, we check for three potential error cases in all applicable spaces:
Expand Down Expand Up @@ -139,7 +143,7 @@ export async function preflightCheckForCreate(params: PreflightCheckForCreatePar
for (let i = 0; i < spaces.size; i++) {
const aliasDoc = bulkGetResponse?.body.docs[getResponseIndex++];
const index = aliasSpacesIndex++; // increment whether the alias was found or not
if (aliasDoc?.found) {
if (isMgetDoc(aliasDoc) && aliasDoc.found) {
const legacyUrlAlias: LegacyUrlAlias | undefined =
aliasDoc._source![LEGACY_URL_ALIAS_TYPE]; // if the 'disabled' field is not present, the source will be empty
if (!legacyUrlAlias?.disabled) {
Expand All @@ -160,7 +164,7 @@ export async function preflightCheckForCreate(params: PreflightCheckForCreatePar
}

let existingDocument: PreflightCheckForCreateResult['existingDocument'];
if (objectDoc.found) {
if (isMgetDoc(objectDoc) && objectDoc.found) {
// @ts-expect-error MultiGetHit._source is optional
if (!rawDocExistsInNamespaces(registry, objectDoc, [...spaces])) {
const error = {
Expand Down
22 changes: 17 additions & 5 deletions src/core/server/saved_objects/service/lib/repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ describe('SavedObjectsRepository', () => {
describe('returns', () => {
const expectSuccessResult = (
{ type, id }: TypeIdTuple,
doc: estypes.MgetHit<SavedObjectsRawDocSource>
doc: estypes.GetGetResult<SavedObjectsRawDocSource>
) => ({
type,
id,
Expand Down Expand Up @@ -1356,8 +1356,14 @@ describe('SavedObjectsRepository', () => {
expect(client.mget).toHaveBeenCalledTimes(1);
expect(result).toEqual({
saved_objects: [
expectSuccessResult(obj1, response.docs[0]),
expectSuccessResult(obj2, response.docs[1]),
expectSuccessResult(
obj1,
response.docs[0] as estypes.GetGetResult<SavedObjectsRawDocSource>
),
expectSuccessResult(
obj2,
response.docs[1] as estypes.GetGetResult<SavedObjectsRawDocSource>
),
],
});
});
Expand All @@ -1377,9 +1383,15 @@ describe('SavedObjectsRepository', () => {
expect(client.mget).toHaveBeenCalledTimes(1);
expect(result).toEqual({
saved_objects: [
expectSuccessResult(obj1, response.docs[0]),
expectSuccessResult(
obj1,
response.docs[0] as estypes.GetGetResult<SavedObjectsRawDocSource>
),
expectError(obj),
expectSuccessResult(obj2, response.docs[1]),
expectSuccessResult(
obj2,
response.docs[1] as estypes.GetGetResult<SavedObjectsRawDocSource>
),
],
});
});
Expand Down
8 changes: 6 additions & 2 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ interface PreflightCheckNamespacesResult {
rawDocSource?: GetResponseFound<SavedObjectsRawDocSource>;
}

function isMgetDoc(doc?: estypes.MgetResponseItem<unknown>): doc is estypes.GetGetResult {
return Boolean(doc && 'found' in doc);
}

/**
* @public
*/
Expand Down Expand Up @@ -647,7 +651,7 @@ export class SavedObjectsRepository {

const { type, id, esRequestIndex } = expectedResult.value;
const doc = bulkGetResponse?.body.docs[esRequestIndex];
if (doc?.found) {
if (isMgetDoc(doc) && doc.found) {
errors.push({
id,
type,
Expand Down Expand Up @@ -1497,7 +1501,7 @@ export class SavedObjectsRepository {
if (esRequestIndex !== undefined) {
const indexFound = bulkGetResponse?.statusCode !== 404;
const actualResult = indexFound ? bulkGetResponse?.body.docs[esRequestIndex] : undefined;
const docFound = indexFound && actualResult?.found === true;
const docFound = indexFound && isMgetDoc(actualResult) && actualResult.found;
if (
!docFound ||
// @ts-expect-error MultiGetHit is incorrectly missing _id, _source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface GetSearchDslOptions {
rootSearchFields?: string[];
searchAfter?: estypes.Id[];
sortField?: string;
sortOrder?: estypes.SearchSortOrder;
sortOrder?: estypes.SortOrder;
namespaces?: string[];
pit?: SavedObjectsPitParams;
typeToNamespacesMap?: Map<string, string[] | undefined>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function getSortingParams(
mappings: IndexMapping,
type: string | string[],
sortField?: string,
sortOrder?: estypes.SearchSortOrder
): { sort?: estypes.SearchSortContainer[] } {
sortOrder?: estypes.SortOrder
): { sort?: estypes.SortCombinations[] } {
if (!sortField) {
return {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ type ObjectToDeleteAliasesFor = Pick<

const MAX_CONCURRENT_ALIAS_DELETIONS = 10;

function isMgetError(doc?: estypes.MgetResponseItem<unknown>): doc is estypes.MgetMultiGetError {
return Boolean(doc && 'error' in doc);
}
/**
* Gets all references and transitive references of the given objects. Ignores any object and/or reference that is not a multi-namespace
* type.
Expand Down Expand Up @@ -224,15 +227,21 @@ export async function updateObjectsSpaces({
let versionProperties;
if (esRequestIndex !== undefined) {
const doc = bulkGetResponse?.body.docs[esRequestIndex];
// @ts-expect-error MultiGetHit._source is optional
if (!doc?.found || !rawDocExistsInNamespace(registry, doc, namespace)) {
const isErrorDoc = isMgetError(doc);

if (
isErrorDoc ||
!doc?.found ||
// @ts-expect-error MultiGetHit._source is optional
!rawDocExistsInNamespace(registry, doc, namespace)
) {
const error = errorContent(SavedObjectsErrorHelpers.createGenericNotFoundError(type, id));
return {
tag: 'Left',
value: { id, type, spaces: [], error },
};
}
currentSpaces = doc._source?.namespaces ?? [];
currentSpaces = doc?._source?.namespaces ?? [];
// @ts-expect-error MultiGetHit._source is optional
versionProperties = getExpectedVersionProperties(version, doc);
} else if (spaces?.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/saved_objects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface SavedObjectsFindOptions {
page?: number;
perPage?: number;
sortField?: string;
sortOrder?: estypes.SearchSortOrder;
sortOrder?: estypes.SortOrder;
/**
* An array of fields to include in the results
* @example
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,7 @@ export interface SavedObjectsFindOptions {
// (undocumented)
sortField?: string;
// (undocumented)
sortOrder?: estypes.SearchSortOrder;
sortOrder?: estypes.SortOrder;
// (undocumented)
type: string | string[];
typeToNamespacesMap?: Map<string, string[] | undefined>;
Expand Down
Loading