oven-sh/bun · error
Failed to find available image: ${imageId}
Error message
Failed to find available image: ${imageId} What it means
getAvailableImage() waits for an AMI to become available (`ec2 wait image-available`), then re-describes it filtered to state=available; the error means the image id is no longer listed as available — it failed to build, was deregistered, or the describe filters (owner) no longer match.
Source
Thrown at scripts/machine.mjs:351
*/
async getAvailableImage(imageOrImageId) {
let imageId = imageOrImageId;
if (typeof imageOrImageId === "object") {
const { ImageId, State } = imageOrImageId;
if (State === "available") {
return imageOrImageId;
}
imageId = ImageId;
}
await aws.waitImage("image-available", imageId);
const [availableImage] = await aws.describeImages({
"state": "available",
"image-id": imageId,
});
if (!availableImage) {
throw new Error(`Failed to find available image: ${imageId}`);
}
return availableImage;
},
/**
* @param {MachineOptions} options
* @returns {Promise<AwsImage>}
*/
async getBaseImage(options) {
const { os, arch, distro, release } = options;
let name, owner;
if (os === "linux") {
if (!distro || distro === "debian") {
owner = "amazon";
name = `debian-${release || "*"}-${arch === "aarch64" ? "arm64" : "amd64"}-*`;
} else if (distro === "ubuntu") {View on GitHub (pinned to 8c5296ac45)
Solutions
- Check the image's real state: `aws ec2 describe-images --image-ids <id> --region <region>` (State: available/failed/pending)
- If State is 'failed', rebuild the image from scratch
- Avoid concurrent jobs that deregister the same AMI
- Retry after a short delay if it was pure consistency lag
Defensive patterns
Strategy: retry
Validate before calling
const state = await $`aws ec2 describe-images --image-ids ${imageId} --query 'Images[0].State'`.text();
if (state.trim() === 'failed') {
throw new Error(`AMI ${imageId} failed to build — rebuild it instead of waiting`);
} Prevention
- Never deregister an AMI another job may be waiting on — serialize publish pipelines
- After `ec2 wait image-available`, re-check State rather than assuming success
- Treat 'failed' images as rebuild-worthy, not retry-worthy
When it happens
Trigger: The pending image transitioned to 'failed' after the waiter returned; a concurrent CI job deregistered the AMI between wait and describe; describing with an owner filter that excludes the image's actual owner.
Common situations: Packer/EC2 image bake failed mid-way leaving a dead AMI id; overlapping publish pipelines deregistering each other's images.
Related errors
- Failed to run instances: ${inspect(instanceOptions)}
- No base image found: ${inspect(options)}
- Failed to get password data for instance: ${instanceId}
- Failed to import key pair: ${keyName}
- BUILDKITE_AGENT_TOKEN not set and no existing buildkite-agen
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/e43040a6eed9a516.
Report an issue: GitHub.