Skip to content

Commit c8287e6

Browse files
committed
feat: some optimization
Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
1 parent 0204d64 commit c8287e6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/core/server/saved_objects/import/create_saved_objects.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const createSavedObjects = async <T>({
113113
// remap results to reflect the object IDs that were submitted for import
114114
// this ensures that consumers understand the results
115115
const remappedResults = expectedResults.map<CreatedObject<T>>((result) => {
116-
const { id } = objectIdMap.get(`${result.type}:${result.id}`)!;
116+
const { id } = objectIdMap.get(`${result.type}:${result.id}`) || ({} as SavedObject<T>);
117117
// also, include a `destinationId` field if the object create attempt was made with a different ID
118118
return { ...result, id, ...(id !== result.id && { destinationId: result.id }) };
119119
});

src/core/server/saved_objects/service/lib/repository.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ export class SavedObjectsRepository {
405405
method,
406406
} = expectedBulkGetResult.value;
407407
let savedObjectWorkspaces: string[] | undefined;
408-
if (object.workspaces) {
408+
if (expectedBulkGetResult.value.method === 'create') {
409+
savedObjectWorkspaces = Array.from(new Set([...(options.workspaces || [])]));
410+
} else if (object.workspaces) {
409411
savedObjectWorkspaces = Array.from(
410412
new Set([...object.workspaces, ...(options.workspaces || [])])
411413
);

0 commit comments

Comments
 (0)