{"record":{"id":"3c1bdab16721ce9d","repo":"dagger/dagger","slug":"parsing-q-image-ref-w","errorCode":null,"errorMessage":"parsing %q image ref: %w","messagePattern":"parsing %q image ref: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/python/runtime/image.go","lineNumber":121,"sourceCode":"\t}\n\treturn Image{named: named}, nil\n}\n\n// extractImages reads from the bundled Dockerfile to extract the default docker\n// image references.\nfunc extractImages() (map[string]Image, error) {\n\timages := make(map[string]Image)\n\tfor _, dockerfile := range []string{baseDockerfile, uvDockerfile} {\n\t\tlines := strings.Split(dockerfile, \"\\n\")\n\n\t\tfor _, line := range lines {\n\t\t\tif matches := fromLineRegex.FindStringSubmatch(strings.TrimSpace(line)); matches != nil {\n\t\t\t\tref := matches[1]\n\t\t\t\tname := matches[2]\n\n\t\t\t\timage, err := NewImage(ref)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"parsing %q image ref: %w\", name, err)\n\t\t\t\t}\n\n\t\t\t\timages[name] = image\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, name := range baseImageNames {\n\t\tif _, found := images[name]; !found {\n\t\t\treturn nil, fmt.Errorf(\"unable to find %q image ref\", name)\n\t\t}\n\t}\n\n\treturn images, nil\n}\n","sourceCodeStart":103,"sourceCodeEnd":137,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/sdk/python/runtime/image.go#L103-L137","documentation":"The Python SDK runtime parses the FROM lines of its embedded base/uv Dockerfiles at discovery time to learn the default image references. If `NewImage` (which calls distribution/reference's ParseNormalizedNamed) fails to parse a ref found in those Dockerfiles, extraction aborts with this wrapped error naming the Dockerfile stage.","triggerScenarios":"A FROM line in sdk/python/runtime/images/base/Dockerfile or images/uv/Dockerfile contains a malformed or empty image reference (e.g. a build arg left unresolved like ${BASE_IMAGE}, or an invalid registry/name/tag), so reference.ParseNormalizedNamed rejects it during NewDiscovery.","commonSituations":"Dagger SDK maintainers editing the bundled Dockerfiles (renaming stages, templating image names, bumping base images) and producing a ref the Docker parser cannot normalize; it is essentially an internal/CI error, not something module authors cause.","solutions":["Inspect the wrapped inner error to find the offending stage name in the message and fix the FROM line in the corresponding Dockerfile under sdk/python/runtime/images/","Ensure no unresolved build args or variables are used as image refs in the embedded Dockerfiles","Validate the ref locally, e.g. `docker build` the Dockerfile or run a quick reference.ParseNormalizedNamed check","Update/upgrade Dagger if the Dockerfiles in your installed version are corrupted"],"exampleFix":"// before\nFROM ${BASE_IMAGE} AS base\n// after\nFROM python:3.12-slim AS base","handlingStrategy":"validation","validationCode":"import re\nFROM_RE = re.compile(r'^FROM\\s+(\\S+)\\s+AS\\s+(\\S+)')\nfor line in open('sdk/python/runtime/images/base/Dockerfile'):\n    m = FROM_RE.match(line.strip())\n    if m:\n        assert '/' in m.group(1) or m.group(1).count('.') or ':' in m.group(1), f'bad ref: {m.group(1)}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use unresolved variables (${VAR}) as image refs in embedded Dockerfiles","Validate Dockerfiles with `docker build` or hadolint before committing","Keep FROM ... AS on a single, well-formed line"],"tags":["go","image-reference","dagger-sdk","internal"],"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"}