{"record":{"id":"9b0bae0d3921e26d","repo":"dagger/dagger","slug":"pushed-image-is-nil","errorCode":null,"errorMessage":"pushed image is nil","messagePattern":"pushed image is nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/server/resolver/resolver.go","lineNumber":641,"sourceCode":"\tmediaType, err := imageutil.DetectManifestMediaType(ra)\n\tif err != nil {\n\t\treturn ocispecs.Descriptor{}, false, err\n\t}\n\treturn ocispecs.Descriptor{\n\t\tDigest:    dgst,\n\t\tSize:      ra.Size(),\n\t\tMediaType: mediaType,\n\t}, true, nil\n}\n\nfunc (r *Resolver) PushImage(ctx context.Context, img *PushedImage, ref string, opts PushOpts) (rerr error) {\n\tspan, ctx := tracing.StartSpan(ctx, \"pushing \"+ref, telemetry.Encapsulated(), telemetry.Encapsulate())\n\tdefer func() {\n\t\ttracing.FinishWithError(span, rerr)\n\t}()\n\n\tif img == nil {\n\t\treturn errors.New(\"pushed image is nil\")\n\t}\n\n\tctx = contentutil.RegisterContentPayloadTypes(ctx)\n\trootDesc := img.RootDesc\n\tparsedRef, err := reference.ParseNormalizedNamed(ref)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif opts.ByDigest {\n\t\tref = parsedRef.Name()\n\t} else {\n\t\trefWithDigest, err := reference.WithDigest(reference.TagNameOnly(parsedRef), rootDesc.Digest)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tref = refWithDigest.String()\n\t}\n","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/server/resolver/resolver.go#L623-L659","documentation":"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.","triggerScenarios":"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).","commonSituations":"Code that constructs an Image via an API whose error was ignored, then pushes the nil result; refactors dropping an early nil check.","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"],"exampleFix":"// before\nimg, _ := buildResult.GetImage(ctx)\nPushImage(ctx, ref, img)\n// after\nimg, err := buildResult.GetImage(ctx)\nif err != nil { return err }\nif img == nil { return errors.New(\"build produced no image\") }\nPushImage(ctx, ref, img)","handlingStrategy":"validation","validationCode":"if img == nil {\n    return errors.New(\"refusing to push: image is nil (build failed to produce an image?)\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["push","programming-error","nil"],"backgroundTag":"nil-image-push","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}