Skip to content

Commit

Permalink
[Fleet] Fix formatNonFatal error typings and avoid type error (elasti…
Browse files Browse the repository at this point in the history
…c#119203) (elastic#119241)

Co-authored-by: Nicolas Chaulet <[email protected]>
  • Loading branch information
kibanamachine and nchaulet authored Nov 19, 2021
1 parent db0ccdd commit f70af1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const upgradeManagedPackagePolicies = async (
if (dryRunResults.hasErrors) {
const errors = dryRunResults.diff
? dryRunResults.diff?.[1].errors
: dryRunResults.body?.message;
: [dryRunResults.body?.message];

appContextService
.getLogger()
Expand Down
9 changes: 8 additions & 1 deletion x-pack/plugins/fleet/server/services/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,15 @@ export function formatNonFatalErrors(
name: e.error.name,
message: e.error.message,
};
} else {
} else if ('errors' in e) {
return e.errors.map((upgradePackagePolicyError: any) => {
if (typeof upgradePackagePolicyError === 'string') {
return {
name: 'SetupNonFatalError',
message: upgradePackagePolicyError,
};
}

return {
name: upgradePackagePolicyError.key,
message: upgradePackagePolicyError.message,
Expand Down

0 comments on commit f70af1a

Please sign in to comment.