From c8622ac785ae4629aece17db9fe1bf9995dfb02b Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Fri, 22 Nov 2024 13:06:32 -0500 Subject: [PATCH] cleanup --- api-client/src/runs/types.ts | 2 +- .../ErrorRecoveryFlows/hooks/useRecoveryCommands.ts | 6 ++++-- .../resources/runs/useUpdateRecoveryPolicyWithStrategy.ts | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api-client/src/runs/types.ts b/api-client/src/runs/types.ts index 80583c5863f..e41626b6448 100644 --- a/api-client/src/runs/types.ts +++ b/api-client/src/runs/types.ts @@ -204,7 +204,7 @@ export interface UpdateErrorRecoveryPolicyRequest { } export type UpdateErrorRecoveryPolicyResponse = Record -export type ErrorRecoveryPolicyResponse = ErrorRecoveryPolicy +export type ErrorRecoveryPolicyResponse = UpdateErrorRecoveryPolicyRequest /** * Current Run State Data diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts index 577528d506a..3e4b20225c5 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts @@ -229,8 +229,10 @@ export function useRecoveryCommands({ return updateErrorRecoveryPolicy(ignorePolicyRules, 'append') .then(() => Promise.resolve()) - .catch(() => - Promise.reject(new Error('Failed to update recovery policy.')) + .catch((e: Error) => + Promise.reject( + new Error(`Failed to update recovery policy: ${e.message}`) + ) ) } else { void proceedToRouteAndStep(RECOVERY_MAP.ERROR_WHILE_RECOVERING.ROUTE) diff --git a/app/src/resources/runs/useUpdateRecoveryPolicyWithStrategy.ts b/app/src/resources/runs/useUpdateRecoveryPolicyWithStrategy.ts index 7e47a86d76f..f26eb507afc 100644 --- a/app/src/resources/runs/useUpdateRecoveryPolicyWithStrategy.ts +++ b/app/src/resources/runs/useUpdateRecoveryPolicyWithStrategy.ts @@ -38,7 +38,7 @@ export function useUpdateRecoveryPolicyWithStrategy( strategy: UpdateErrorRecoveryPolicyWithStrategy['strategy'] ) => getErrorRecoveryPolicy(host as HostConfig, runId).then(res => { - const existingPolicyRules = res.data.policyRules.map(rule => ({ + const existingPolicyRules = res.data.data.policyRules.map(rule => ({ commandType: rule.matchCriteria.command.commandType, errorType: rule.matchCriteria.command.error.errorType, ifMatch: rule.ifMatch, @@ -49,7 +49,7 @@ export function useUpdateRecoveryPolicyWithStrategy( case 'append': return [...existingPolicyRules, newPolicy] default: { - console.error('Handled policy strategy, using append.') + console.error('Unhandled policy strategy, defaulting to append.') return [...existingPolicyRules, newPolicy] } }