From 9b70364940903f9d5f4a320f5d572c4377ab33b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 23:08:14 +0000 Subject: [PATCH 1/8] Include stack traces in catchSpectralRunErrors for improved debugging Agent-Logs-Url: https://github.com/Azure/azure-openapi-validator/sessions/c4858aed-3151-47c9-8dfd-dbcde93b9efc Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com> --- .../autorest/src/spectral-plugin-utils.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index ea077b798..91b313c68 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -159,11 +159,19 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut // Initialize an array to collect error messages const errorMessages: string[] = [error] + // Include the stack trace from the top-level error if available + if (error && error.stack) { + errorMessages.push(`Stack trace:\n${error.stack}`) + } + // Check if "error" contains the "errors" property if (error && error.errors && Array.isArray(error.errors)) { - error.errors.forEach((error: any, index: number) => { - // Push each error message into the array - errorMessages.push(`Error ${index + 1}: ${error.message}`) + error.errors.forEach((innerError: any, index: number) => { + // Push each error message and stack trace into the array + errorMessages.push(`Error ${index + 1}: ${innerError.message}`) + if (innerError.stack) { + errorMessages.push(`Stack trace for error ${index + 1}:\n${innerError.stack}`) + } }) } From b8498414b133423d7ec5260c147172ec7c92c831 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Mar 2026 16:25:31 -0700 Subject: [PATCH 2/8] Apply suggestion from @mikeharder --- .../autorest/src/spectral-plugin-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index 91b313c68..85a11f49c 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -170,7 +170,7 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut // Push each error message and stack trace into the array errorMessages.push(`Error ${index + 1}: ${innerError.message}`) if (innerError.stack) { - errorMessages.push(`Stack trace for error ${index + 1}:\n${innerError.stack}`) + errorMessages.push(`Stack ${index + 1}:\n${innerError.stack}`) } }) } From 1cb85452a5a7fd8f3e990419ffee333a3e3173d2 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Mar 2026 16:26:11 -0700 Subject: [PATCH 3/8] Apply suggestion from @mikeharder --- .../autorest/src/spectral-plugin-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index 85a11f49c..ae4062744 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -166,7 +166,7 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut // Check if "error" contains the "errors" property if (error && error.errors && Array.isArray(error.errors)) { - error.errors.forEach((innerError: any, index: number) => { + error.errors.forEach((error: any, index: number) => { // Push each error message and stack trace into the array errorMessages.push(`Error ${index + 1}: ${innerError.message}`) if (innerError.stack) { From d6782271f836bc9f8183c75ecd26c5460f5bed37 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Mar 2026 16:26:39 -0700 Subject: [PATCH 4/8] Apply suggestion from @mikeharder --- .../autorest/src/spectral-plugin-utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index ae4062744..0ed69652c 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -167,8 +167,8 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut // Check if "error" contains the "errors" property if (error && error.errors && Array.isArray(error.errors)) { error.errors.forEach((error: any, index: number) => { - // Push each error message and stack trace into the array - errorMessages.push(`Error ${index + 1}: ${innerError.message}`) + // Push each error message into the array + errorMessages.push(`Error ${index + 1}: ${error.message}`) if (innerError.stack) { errorMessages.push(`Stack ${index + 1}:\n${innerError.stack}`) } From 4a8564b697462059ae6d97219d8cda769718cd51 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Mar 2026 16:26:53 -0700 Subject: [PATCH 5/8] Apply suggestion from @mikeharder --- .../autorest/src/spectral-plugin-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index 0ed69652c..423ff0ad4 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -169,7 +169,7 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut error.errors.forEach((error: any, index: number) => { // Push each error message into the array errorMessages.push(`Error ${index + 1}: ${error.message}`) - if (innerError.stack) { + if (error.stack) { errorMessages.push(`Stack ${index + 1}:\n${innerError.stack}`) } }) From f113f341ae62dd599e595b12408753f224060b94 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Mar 2026 16:27:07 -0700 Subject: [PATCH 6/8] Apply suggestion from @mikeharder --- .../autorest/src/spectral-plugin-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index 423ff0ad4..720aa45a7 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -170,7 +170,7 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut // Push each error message into the array errorMessages.push(`Error ${index + 1}: ${error.message}`) if (error.stack) { - errorMessages.push(`Stack ${index + 1}:\n${innerError.stack}`) + errorMessages.push(`Stack ${index + 1}:\n${error.stack}`) } }) } From c8ee673c4dfeb41d5fc9a1262c215255ef65b338 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Mar 2026 16:27:55 -0700 Subject: [PATCH 7/8] Apply suggestion from @mikeharder --- .../autorest/src/spectral-plugin-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index 720aa45a7..0949b86ba 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -161,7 +161,7 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut // Include the stack trace from the top-level error if available if (error && error.stack) { - errorMessages.push(`Stack trace:\n${error.stack}`) + errorMessages.push(`Stack:\n${error.stack}`) } // Check if "error" contains the "errors" property From 1fc600e96ace0bbcab4faf5babe55fe0c1d6c16f Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Mar 2026 16:28:58 -0700 Subject: [PATCH 8/8] Apply suggestion from @mikeharder --- .../autorest/src/spectral-plugin-utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index 0949b86ba..50b84ec51 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -159,7 +159,6 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut // Initialize an array to collect error messages const errorMessages: string[] = [error] - // Include the stack trace from the top-level error if available if (error && error.stack) { errorMessages.push(`Stack:\n${error.stack}`) }