heygen-com/hyperframes · error · Error
[lambda] sam delete exited with code ${result.status ?? "unk
Error message
[lambda] sam delete exited with code ${result.status ?? "unknown"} What it means
Thrown by samDelete() in packages/cli/src/commands/lambda/sam.ts:135 when `sam delete --no-prompts` exits non-zero. Unlike the deploy error, no diagnostic hint is appended — the message reports only the exit code, so the operator must consult the streamed SAM output for the cause.
Source
Thrown at packages/cli/src/commands/lambda/sam.ts:136
}
/** Run `sam delete` non-interactively. */
export function samDelete(opts: {
repoRoot: string;
stackName: string;
region: string;
awsProfile?: string;
stdio?: "inherit" | "pipe";
}): void {
assertSamAvailable();
const args = ["delete", "--stack-name", opts.stackName, "--region", opts.region, "--no-prompts"];
if (opts.awsProfile) {
args.push("--profile", opts.awsProfile);
}
const samDir = join(opts.repoRoot, "examples", "aws-lambda");
const result = spawnSync("sam", args, { cwd: samDir, stdio: opts.stdio ?? "inherit" });
if (result.status !== 0) {
throw new Error(`[lambda] sam delete exited with code ${result.status ?? "unknown"}`);
}
}
export interface StackOutputBag {
bucketName: string;
functionName: string;
stateMachineArn: string;
}
/**
* Query CloudFormation for the stack outputs the SAM template exports.
* Used after `samDeploy` to populate the local state file.
*/
export function fetchStackOutputs(opts: {
stackName: string;
region: string;
awsProfile?: string;
}): StackOutputBag {View on GitHub (pinned to c2996c8626)
Solutions
- Confirm the stack exists in the region: `aws cloudformation describe-stacks --stack-name <name> --region <region>`.
- Check the SAM output streamed to stderr/stdout above the thrown error for the precise failure.
- Verify --aws-profile has delete permissions and the region matches the deploy region.
- If SAM keeps failing, fall back to `aws cloudformation delete-stack --stack-name <name> --region <region>` directly.
Example fix
# before hyperframes lambda destroy # exits non-zero on missing stack # after aws cloudformation describe-stacks --stack-name <name> --region us-east-1 # if not found, nothing to delete; otherwise: aws cloudformation delete-stack --stack-name <name> --region us-east-1
Defensive patterns
Strategy: try-catch
Validate before calling
import { execFileSync } from 'node:child_process';
function stackExists(name: string, region: string, profile?: string): boolean {
const args = ['cloudformation', 'describe-stacks', '--stack-name', name, '--region', region];
if (profile) args.unshift('--profile', profile);
try {
execFileSync('aws', args, { stdio: 'ignore' });
return true;
} catch {
return false;
}
} Try / catch
try {
samDelete(opts);
} catch (error) {
if (/does not exist/i.test(String(error)) || /ValidationError/.test(String(error))) {
// stack already gone — treat as success
return;
}
throw error;
} Prevention
- Check stack existence in the region before calling destroy.
- Treat 'stack does not exist' as a no-op success in destroy wrappers.
- Confirm the SAM CLI version installed accepts --no-prompts.
When it happens
Trigger: samDelete against a stack that does not exist in the given region, with the wrong profile, with insufficient delete permissions, or when the installed SAM CLI version rejects the --no-prompts flag.
Common situations: Stack already deleted (or never created) in that region; --region mismatch with where the stack lives; AWS credentials lack cloudformation:DeleteStack; SAM CLI version drift.
Related errors
- [lambda] sam deploy exited with code ${result.status ?? "unk
- [lambda] stack ${opts.stackName} is missing one of RenderBuc
- `aws` CLI not found on PATH. Install from https://docs.aws.a
- [lambda] SAM template not found at ${candidate}. If you're r
- [build-zip] unzipped bundle ${formatBytes(unzippedBytes)} ex
AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12).
Data as JSON: /api/errors/ed7444071b0c4279.
Report an issue: GitHub.