From 426ecd7f5d7fdb64e9b5271aef6c08b6f474503f Mon Sep 17 00:00:00 2001 From: dgandhi62 Date: Fri, 25 Sep 2026 11:01:53 -0400 Subject: [PATCH 1/2] chore: add better error handling --- .../@aws-cdk-testing/cli-integ/lib/shell.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/@aws-cdk-testing/cli-integ/lib/shell.ts b/packages/@aws-cdk-testing/cli-integ/lib/shell.ts index 0dacfe703..b5cbdcdf5 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/shell.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/shell.ts @@ -133,6 +133,23 @@ export async function shell(command: string[], options: ShellOptions = {}): Prom if (code === 0 || options.allowErrExit) { resolve(out); + } else if (code === 127) { + // Exit 127 is the shell's "command not found". It means the executable + // named in the command wasn't resolvable on PATH when this ran — NOT + // that the command itself did something wrong. This most often happens + // when the CLI-under-test isn't installed/on PATH, or when the test's + // environment has already been torn down (e.g. this shell ran after the + // test was killed on timeout). Surfacing that here keeps investigators + // from chasing the named command (e.g. `cdk synth`) instead of the real + // cause. + logAndReject(new Error( + `'${command.join(' ')}' exited with error code 127 (command not found): ` + + `'${command[0]}' was not resolvable on PATH when it ran. ` + + 'This usually means the executable is not installed or not on PATH, ' + + 'or the test environment was torn down before this command ran ' + + '(for example, after the test was killed on timeout) — not a defect in ' + + `'${command[0]}' itself.`, + )); } else { logAndReject(new Error(`'${command.join(' ')}' exited with error code ${code}.`)); } From ca49d9d0e9c2840656879e20f08fe79e5c02f1a3 Mon Sep 17 00:00:00 2001 From: dgandhi62 Date: Fri, 25 Sep 2026 11:10:57 -0400 Subject: [PATCH 2/2] fix(cli-integ): attribute exit code 127 as a missing executable A command exiting 127 (POSIX 'command not found') was reported by shell() as a bare 'exited with error code 127', which reads like the named command (e.g. 'cdk synth') itself failed. In canary logs this sent investigators toward CDK/synth instead of the real cause: an executable invoked by the command was not on PATH when it ran. Special-case exit code 127 to state what the failure points to (a missing or unavailable executable) rather than a defect in the named command. --- .../@aws-cdk-testing/cli-integ/lib/shell.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/lib/shell.ts b/packages/@aws-cdk-testing/cli-integ/lib/shell.ts index b5cbdcdf5..0464b5e21 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/shell.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/shell.ts @@ -134,21 +134,11 @@ export async function shell(command: string[], options: ShellOptions = {}): Prom if (code === 0 || options.allowErrExit) { resolve(out); } else if (code === 127) { - // Exit 127 is the shell's "command not found". It means the executable - // named in the command wasn't resolvable on PATH when this ran — NOT - // that the command itself did something wrong. This most often happens - // when the CLI-under-test isn't installed/on PATH, or when the test's - // environment has already been torn down (e.g. this shell ran after the - // test was killed on timeout). Surfacing that here keeps investigators - // from chasing the named command (e.g. `cdk synth`) instead of the real - // cause. logAndReject(new Error( - `'${command.join(' ')}' exited with error code 127 (command not found): ` + - `'${command[0]}' was not resolvable on PATH when it ran. ` + - 'This usually means the executable is not installed or not on PATH, ' + - 'or the test environment was torn down before this command ran ' + - '(for example, after the test was killed on timeout) — not a defect in ' + - `'${command[0]}' itself.`, + `'${command.join(' ')}' exited with error code 127. ` + + 'An executable invoked by this command ' + + 'was not found on PATH when it ran. This points to a missing or ' + + `unavailable executable, not to a failure within '${command[0]}' itself.`, )); } else { logAndReject(new Error(`'${command.join(' ')}' exited with error code ${code}.`));