From 82301e7454c43392d3aac04f9f3d8f64d52c6622 Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Thu, 5 Dec 2024 14:43:29 -0700 Subject: [PATCH] [DataUsage][Serverless] Fix AutoOps error message to drop "agent" reference (#202996) ## Summary This removes the references to "autoops agent" in the error message if the request fails, as it has nothing to do with any agent. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks No. None of the error messages are exported, so they cannot be misused in other places. --- .../data_usage/server/services/autoops_api.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/data_usage/server/services/autoops_api.ts b/x-pack/plugins/data_usage/server/services/autoops_api.ts index d98b0c507fe14..8f371d3004def 100644 --- a/x-pack/plugins/data_usage/server/services/autoops_api.ts +++ b/x-pack/plugins/data_usage/server/services/autoops_api.ts @@ -24,8 +24,7 @@ import { AutoOpsConfig } from '../types'; import { AutoOpsError } from './errors'; import { appContextService } from './app_context'; -const AGENT_CREATION_FAILED_ERROR = 'AutoOps API could not create the autoops agent'; -const AUTO_OPS_AGENT_CREATION_PREFIX = '[AutoOps API] Creating autoops agent failed'; +const AUTO_OPS_REQUEST_FAILED_PREFIX = '[AutoOps API] Request failed'; const AUTO_OPS_MISSING_CONFIG_ERROR = 'Missing autoops configuration'; const getAutoOpsAPIRequestUrl = (url?: string, projectId?: string): string => @@ -120,7 +119,7 @@ export class AutoOpsAPIService { (error: Error | AxiosError) => { if (!axios.isAxiosError(error)) { this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} with an error ${error} ${requestConfigDebugStatus}`, + `${AUTO_OPS_REQUEST_FAILED_PREFIX} with an error ${error}, request config: ${requestConfigDebugStatus}`, errorMetadataWithRequestConfig ); throw new AutoOpsError(withRequestIdMessage(error.message)); @@ -131,9 +130,11 @@ export class AutoOpsAPIService { if (error.response) { // The request was made and the server responded with a status code and error data this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} because the AutoOps API responded with a status code that falls out of the range of 2xx: ${JSON.stringify( + `${AUTO_OPS_REQUEST_FAILED_PREFIX} because the AutoOps API responded with a status code that falls out of the range of 2xx: ${JSON.stringify( error.response.status - )}} ${JSON.stringify(error.response.data)}} ${requestConfigDebugStatus}`, + )}} ${JSON.stringify( + error.response.data + )}}, request config: ${requestConfigDebugStatus}`, { ...errorMetadataWithRequestConfig, http: { @@ -145,22 +146,22 @@ export class AutoOpsAPIService { }, } ); - throw new AutoOpsError(withRequestIdMessage(AGENT_CREATION_FAILED_ERROR)); + throw new AutoOpsError(withRequestIdMessage(AUTO_OPS_REQUEST_FAILED_PREFIX)); } else if (error.request) { // The request was made but no response was received this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} while sending the request to the AutoOps API: ${errorLogCodeCause} ${requestConfigDebugStatus}`, + `${AUTO_OPS_REQUEST_FAILED_PREFIX} while sending the request to the AutoOps API: ${errorLogCodeCause}, request config: ${requestConfigDebugStatus}`, errorMetadataWithRequestConfig ); throw new AutoOpsError(withRequestIdMessage(`no response received from the AutoOps API`)); } else { // Something happened in setting up the request that triggered an Error this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} to be created ${errorLogCodeCause} ${requestConfigDebugStatus} ${error.toJSON()}`, + `${AUTO_OPS_REQUEST_FAILED_PREFIX} with ${errorLogCodeCause}, request config: ${requestConfigDebugStatus}, error: ${error.toJSON()}`, errorMetadataWithRequestConfig ); throw new AutoOpsError( - withRequestIdMessage(`${AGENT_CREATION_FAILED_ERROR}, ${error.message}`) + withRequestIdMessage(`${AUTO_OPS_REQUEST_FAILED_PREFIX}, ${error.message}`) ); } }