{"record":{"id":"f6bffa95576aafa2","repo":"microsoft/aspire","slug":"invalid-digest-format","errorCode":null,"errorMessage":"invalid digest format","messagePattern":"invalid digest format","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs","lineNumber":450,"sourceCode":"            ? $\"{parsedReference.Registry}/{parsedReference.Image}\"\n            : parsedReference.Image;\n\n        if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } imageAnnotation)\n        {\n            imageAnnotation.Image = parsedRegistryAndImage;\n        }\n        else\n        {\n            imageAnnotation = new ContainerImageAnnotation { Image = parsedRegistryAndImage };\n            builder.Resource.Annotations.Add(imageAnnotation);\n        }\n\n        if (parsedReference.Digest is { })\n        {\n            const string prefix = \"sha256:\";\n            if (!parsedReference.Digest.StartsWith(prefix, StringComparison.Ordinal))\n            {\n                throw new ArgumentOutOfRangeException(nameof(image), parsedReference.Digest, \"invalid digest format\");\n            }\n\n            var digest = parsedReference.Digest[prefix.Length..];\n            imageAnnotation.SHA256 = digest;\n        }\n        else\n        {\n            imageAnnotation.Tag = parsedReference.Tag ?? tag ?? \"latest\";\n        }\n\n        // If there's a DockerfileBuildAnnotation with an image name/tag, clear them\n        // so that the user's explicit image preference is respected\n        if (builder.Resource.Annotations.OfType<DockerfileBuildAnnotation>().SingleOrDefault() is { } buildAnnotation)\n        {\n            buildAnnotation.ImageName = null;\n            buildAnnotation.ImageTag = null;\n        }\n","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs#L432-L468","documentation":"When the image reference passed to WithImage contains a digest, the library requires the digest to use the sha256: algorithm prefix. Any other digest format (e.g. sha512: or a bare hex string) triggers this ArgumentOutOfRangeException naming the image parameter.","triggerScenarios":"Calling WithImage with a reference like \"myrepo/myapp@sha512:...\" or \"myrepo/myapp@abcdef0123\" (digest without the sha256: prefix).","commonSituations":"Copying image references that use non-sha256 algorithms; hand-editing image strings and dropping the 'sha256:' prefix; registries or tooling that emit other digest algorithms.","solutions":["Use a sha256 digest: convert the image reference to the form myrepo/myapp@sha256:<64-hex-chars>.","Get the correct sha256 digest from the registry (e.g. docker inspect or crane digest).","If only tag pinning is needed, drop the digest and use the tag parameter or WithImageSHA256 with the hex portion.","exampleFix placeholder"],"exampleFix":"// before\n.WithImage(\"myrepo/myapp@sha512:deadbeef...\");\n// after\n.WithImage(\"myrepo/myapp@sha256:8d4f3a5b...\");","handlingStrategy":"validation","validationCode":"var parsed = ContainerReferenceParser.Parse(image);\nif (parsed.Digest is { } digest && !digest.StartsWith(\"sha256:\", StringComparison.Ordinal))\n    throw new ArgumentException($\"Digest '{digest}' must use the sha256: algorithm prefix.\", nameof(image));","typeGuard":null,"tryCatchPattern":"try\n{\n    resource.WithImage(image);\n}\ncatch (ArgumentOutOfRangeException ex) when (ex.Message == \"invalid digest format\")\n{\n    // Replace with a sha256 digest and retry\n}","preventionTips":["Only use sha256 digests when pinning images.","Fetch digests with 'docker inspect' or 'crane digest' to guarantee the sha256: prefix.","Never hand-strip the 'sha256:' prefix from an image reference."],"tags":["container-image","digest","validation","aspire"],"backgroundTag":"invalid-argument-format","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}