Skip to content

Commit

Permalink
fix resolve import error api integration test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
yujin-emma committed Feb 1, 2024
1 parent 43702c8 commit efa68fa
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/core/server/saved_objects/routes/resolve_import_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const registerResolveImportErrorsRoute = (router: IRouter, config: SavedO
validate: {
query: schema.object({
createNewCopies: schema.boolean({ defaultValue: false }),
dataSourceId: schema.string({ defaultValue: '' }),
dataSourceId: schema.maybe(schema.string({ defaultValue: '' })),
}),
body: schema.object({
file: schema.stream(),
Expand Down Expand Up @@ -93,17 +93,19 @@ export const registerResolveImportErrorsRoute = (router: IRouter, config: SavedO
const dataSourceId = req.query.dataSourceId;

// get datasource from saved object service
const dataSource = await context.core.savedObjects.client
.get('data-source', dataSourceId)
.then((response) => {
const attributes: any = response?.attributes || {};
return {
id: response.id,
title: attributes.title,
};
});
const dataSource = dataSourceId
? await context.core.savedObjects.client
.get('data-source', dataSourceId)
.then((response) => {
const attributes: any = response?.attributes || {};
return {
id: response.id,
title: attributes.title,
};
})
: '';

const dataSourceTitle = dataSource.title;
const dataSourceTitle = dataSource ? dataSource.title : '';

let readStream: Readable;
try {
Expand Down

0 comments on commit efa68fa

Please sign in to comment.