From 6e9e7d0685e4c1a99518819b170494a6c9e369ec Mon Sep 17 00:00:00 2001 From: zdenekj Date: Thu, 11 Sep 2025 11:30:56 +0200 Subject: [PATCH] EN-569 - Dont log 400 responses as exceptions --- src/telemetry/applicationInsights.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/telemetry/applicationInsights.ts b/src/telemetry/applicationInsights.ts index ec2f92c..344aa15 100644 --- a/src/telemetry/applicationInsights.ts +++ b/src/telemetry/applicationInsights.ts @@ -1,6 +1,6 @@ import { SharedModels } from "@kontent-ai/management-sdk"; import appInsights from "applicationinsights"; -import { AxiosError } from "axios"; +import type { AxiosError } from "axios"; import { sanitizeTelemetry, sanitizeUrl } from "./telemetrySanitizer.js"; let isInitialized = false; @@ -9,6 +9,11 @@ function trackKontentApiError( error: SharedModels.ContentManagementBaseKontentError, context?: string, ): void { + if (error.validationErrors && error.validationErrors.length > 0) { + // Don't log 400 responses as exceptions + return; + } + const safeError = new Error(error.message); safeError.stack = error.originalError.stack || safeError.stack;