dagger/dagger · error
pushed image is nil
Error message
pushed image is nil
What it means
PushImage guards against being handed a nil image; the pushed img must carry a RootDesc descriptor to construct the push. A nil image indicates a programming error upstream rather than a registry problem.
Source
Thrown at engine/server/resolver/resolver.go:641
mediaType, err := imageutil.DetectManifestMediaType(ra)
if err != nil {
return ocispecs.Descriptor{}, false, err
}
return ocispecs.Descriptor{
Digest: dgst,
Size: ra.Size(),
MediaType: mediaType,
}, true, nil
}
func (r *Resolver) PushImage(ctx context.Context, img *PushedImage, ref string, opts PushOpts) (rerr error) {
span, ctx := tracing.StartSpan(ctx, "pushing "+ref, telemetry.Encapsulated(), telemetry.Encapsulate())
defer func() {
tracing.FinishWithError(span, rerr)
}()
if img == nil {
return errors.New("pushed image is nil")
}
ctx = contentutil.RegisterContentPayloadTypes(ctx)
rootDesc := img.RootDesc
parsedRef, err := reference.ParseNormalizedNamed(ref)
if err != nil {
return err
}
if opts.ByDigest {
ref = parsedRef.Name()
} else {
refWithDigest, err := reference.WithDigest(reference.TagNameOnly(parsedRef), rootDesc.Digest)
if err != nil {
return err
}
ref = refWithDigest.String()
}
View on GitHub (pinned to 82ba2681db)
Solutions
- Fix the caller to never pass nil: check the image construction error before pushing
- Add an upstream nil check and return a descriptive error instead of invoking PushImage
- If the image comes from a build result, verify the publish step actually produced an image
Example fix
// before
img, _ := buildResult.GetImage(ctx)
PushImage(ctx, ref, img)
// after
img, err := buildResult.GetImage(ctx)
if err != nil { return err }
if img == nil { return errors.New("build produced no image") }
PushImage(ctx, ref, img) Defensive patterns
Strategy: validation
Validate before calling
if img == nil {
return errors.New("refusing to push: image is nil (build failed to produce an image?)")
} Prevention
- Check errors from image-producing calls before pushing
- Never ignore GetImage/build errors
- Assert non-nil at function boundaries in publish code
- Add unit tests covering failed-build push paths
When it happens
Trigger: Calling PushImage(ctx, ref, nil) or passing the result of a failed/short-circuited image construction (e.g. a published-image variable that was never populated).
Common situations: Code that constructs an Image via an API whose error was ignored, then pushes the nil result; refactors dropping an early nil check.
Related errors
- encode persisted directory: nil directory
- with file: nil source snapshot
- encode persisted git repository: nil repository
- git bundle is required
- cache volume is nil
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/9b0bae0d3921e26d.
Report an issue: GitHub.