From a1fb71e12dacb6375a76d2ef40203d4459dce41f Mon Sep 17 00:00:00 2001 From: Harrison Weinstock Date: Wed, 3 Jun 2026 22:14:42 +0000 Subject: [PATCH 1/4] fix(deploy): remove error context wrapping that removes error typing --- src/cli/cdk/toolkit-lib/wrapper.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/cli/cdk/toolkit-lib/wrapper.ts b/src/cli/cdk/toolkit-lib/wrapper.ts index 4444f2795..1fff8f724 100644 --- a/src/cli/cdk/toolkit-lib/wrapper.ts +++ b/src/cli/cdk/toolkit-lib/wrapper.ts @@ -1,6 +1,6 @@ import { CONFIG_DIR } from '../../../lib'; import { CDK_APP_ENTRY, CDK_PROJECT_DIR } from '../../constants'; -import { getErrorMessage, isChangesetInProgressError } from '../../errors'; +import { isChangesetInProgressError } from '../../errors'; import type { CdkToolkitWrapperOptions, DeployOptions, DestroyOptions, DiffOptions, ListOptions } from './types'; import { BaseCredentials, @@ -36,18 +36,10 @@ async function withErrorContext(context: string, operation: () => Promise) try { return await operation(); } catch (err) { - const message = getErrorMessage(err); - const stack = err instanceof Error ? err.stack : undefined; - const cause = err instanceof Error ? err.cause : undefined; - - const error = new Error(`CDK ${context} failed: ${message}`); - if (stack) { - error.stack = `CDK ${context} failed: ${message}\n\nOriginal stack:\n${stack}`; - } - if (cause) { - error.cause = cause; + if (err instanceof Error) { + err.message = `CDK ${context} failed: ${err.message}`; } - throw error; + throw err; } } From f4c3637620630fcb013410aac1fe9df264546e94 Mon Sep 17 00:00:00 2001 From: Harrison Weinstock Date: Wed, 3 Jun 2026 22:20:14 +0000 Subject: [PATCH 2/4] fix(deploy): use ValidationError for no-resources preflight check --- src/cli/operations/deploy/preflight.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli/operations/deploy/preflight.ts b/src/cli/operations/deploy/preflight.ts index e52ca74a7..13093ef4a 100644 --- a/src/cli/operations/deploy/preflight.ts +++ b/src/cli/operations/deploy/preflight.ts @@ -1,4 +1,5 @@ import { ConfigIO, DOCKERFILE_NAME, getDockerfilePath, requireConfigRoot, resolveCodeLocation } from '../../../lib'; +import { ValidationError } from '../../../lib/errors/types'; import type { AgentCoreProjectSpec, AwsDeploymentTarget } from '../../../schema'; import { validateAwsCredentials } from '../../aws/account'; import { LocalCdkProject } from '../../cdk/local-cdk-project'; @@ -109,7 +110,7 @@ export async function validateProject(): Promise { // No deployed state file — no existing stack } if (!hasExistingStack) { - throw new Error( + throw new ValidationError( 'No resources defined in project. Add at least one resource (agent, memory, evaluator, or gateway) before deploying.' ); } From aa01ee4119e1cc111e6be7d2b49c854e05d3feff Mon Sep 17 00:00:00 2001 From: Harrison Weinstock Date: Wed, 3 Jun 2026 22:20:42 +0000 Subject: [PATCH 3/4] fix(deploy): use ValidationError for runtime name length check --- src/cli/operations/deploy/preflight.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/operations/deploy/preflight.ts b/src/cli/operations/deploy/preflight.ts index 13093ef4a..a60ec4e1d 100644 --- a/src/cli/operations/deploy/preflight.ts +++ b/src/cli/operations/deploy/preflight.ts @@ -145,7 +145,7 @@ function validateRuntimeNames(projectSpec: AgentCoreProjectSpec): void { if (agentName) { const combinedName = `${projectName}_${agentName}`; if (combinedName.length > MAX_RUNTIME_NAME_LENGTH) { - throw new Error( + throw new ValidationError( `Runtime name too long: "${combinedName}" (${combinedName.length} chars). ` + `AWS limits runtime names to ${MAX_RUNTIME_NAME_LENGTH} characters. ` + `Shorten the project name or agent name in agentcore.json.` From d444a40ab836464f7a7aab9c32abb7eabf126b14 Mon Sep 17 00:00:00 2001 From: Harrison Weinstock Date: Wed, 3 Jun 2026 22:21:48 +0000 Subject: [PATCH 4/4] fix(deploy): use ValidationError for teardown confirmation check --- src/cli/commands/deploy/actions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/commands/deploy/actions.ts b/src/cli/commands/deploy/actions.ts index 13f696587..65dbcddb1 100644 --- a/src/cli/commands/deploy/actions.ts +++ b/src/cli/commands/deploy/actions.ts @@ -155,7 +155,7 @@ export async function handleDeploy(options: ValidatedDeployOptions): Promise