{"record":{"id":"cb3731ba3afdb26b","repo":"dagger/dagger","slug":"failed-to-parse-image-address-s-w-cb3731","errorCode":null,"errorMessage":"failed to parse image address %s: %w","messagePattern":"failed to parse image address (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/host.go","lineNumber":762,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn nil, false, err\n\t\t\t}\n\t\t\tmatched = matched || childMatched\n\t\t\tif target != nil {\n\t\t\t\treturn target, true, nil\n\t\t\t}\n\t\t}\n\t\treturn nil, matched, nil\n\n\tdefault:\n\t\treturn nil, false, fmt.Errorf(\"unsupported host image media type %s\", desc.MediaType)\n\t}\n}\n\nfunc (s *hostSchema) containerImage(ctx context.Context, parent dagql.ObjectResult[*core.Host], args hostContainerArgs) (inst dagql.Result[*core.Container], err error) {\n\trefName, err := reference.ParseNormalizedNamed(args.Name)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to parse image address %s: %w\", args.Name, err)\n\t}\n\trefName = reference.TagNameOnly(refName)\n\n\tquery, err := core.CurrentQuery(ctx)\n\tif err != nil {\n\t\treturn inst, err\n\t}\n\tbk, err := query.Engine(ctx)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to get engine client: %w\", err)\n\t}\n\n\timageReader, err := bk.ReadImage(ctx, refName.String())\n\tif err != nil {\n\t\treturn inst, err\n\t}\n\n\tif imageReader.ContentStore != nil && imageReader.ImagesStore != nil {","sourceCodeStart":744,"sourceCodeEnd":780,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/host.go#L744-L780","documentation":"Host.containerImage takes an image name and normalizes it via the Docker reference parser. If the provided string isn't a valid image reference (bad characters, malformed tag/digest, empty), parsing fails and the parse error is wrapped with this message including the original name.","triggerScenarios":"Calling Host.containerImage with an invalid reference string, e.g. \"my image\", \"repo::tag\", a name with uppercase characters, or a URL with a scheme like \"https://registry/img\".","commonSituations":"Passing a full registry URL instead of an image reference, interpolating whitespace or newlines into the name, using uppercase repository names, or typos like double colons in tag/digest.","solutions":["Fix the reference to valid Docker syntax: [registry/]repository[:tag][@digest], lowercase repository.","Strip URL schemes and whitespace before passing the image name.","If the name is dynamic, validate/normalize it first (reference.ParseNormalizedNamed equivalent or regex)."],"exampleFix":"// before\ndag.host().containerImage(\"https://registry.example.com/MyApp:latest\")\n// after\ndag.host().containerImage(\"registry.example.com/myapp:latest\")","handlingStrategy":"validation","validationCode":"const refRe = /^(?:[a-z0-9]+(?:[._-][a-z0-9]+)*(?::\\d+)?\\/)?[a-z0-9]+(?:[._-][a-z0-9]+)*(?:\\/[a-z0-9]+(?:[._-][a-z0-9]+)*)*(?::[\\w][\\w.-]{0,127})?(?:@[A-Za-z][A-Za-z0-9]*(?::[0-9a-fA-F]{32,})?)?$/\nif (!refRe.test(name)) throw new Error(`invalid image reference: ${name}`)","typeGuard":"function isValidImageRef(name) { return typeof name === \"string\" && /^[a-z0-9.\\/:_@-]+$/.test(name.trim()) && !name.includes(\"::\") && !/^https?:\\/\\//.test(name) }","tryCatchPattern":"try { await dag.host().containerImage(name) } catch (e) { if (String(e).includes(\"failed to parse image address\")) throw new Error(`bad image ref '${name}': use [registry/]repo[:tag][@digest], lowercase`); throw e }","preventionTips":["Always use lowercase repo names and no URL schemes.","Trim/validate dynamically built image names before calling the API.","Let Dagger normalize names; don't pre-append defaults like :latest incorrectly."],"tags":["image","reference-parsing","validation"],"backgroundTag":"invalid-image-reference","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"}