{"record":{"id":"b80eed1ed53e1d7b","repo":"amir20/dozzle","slug":"invalid-image-reference-q-empty-tag","errorCode":null,"errorMessage":"invalid image reference %q: empty tag","messagePattern":"invalid image reference %q: empty tag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/imagecheck/reference.go","lineNumber":131,"sourceCode":"\t\t\tremainder = remainder[i+1:]\n\t\t}\n\t}\n\n\t// Docker Hub answers to several names. They have to collapse to one, or a\n\t// reference written as index.docker.io/library/nginx never lines up with\n\t// the \"nginx@sha256:...\" that Docker records locally.\n\tif _, aliased := dockerHubAliases[registry]; aliased {\n\t\tregistry = defaultRegistry\n\t}\n\n\ttag := \"\"\n\t// Only treat a colon as a tag separator when it is not part of a registry\n\t// port, which has already been stripped above.\n\tif i := strings.LastIndex(remainder, \":\"); i != -1 {\n\t\ttag = remainder[i+1:]\n\t\tremainder = remainder[:i]\n\t\tif tag == \"\" {\n\t\t\treturn Reference{}, fmt.Errorf(\"invalid image reference %q: empty tag\", ref)\n\t\t}\n\t}\n\n\tif remainder == \"\" {\n\t\treturn Reference{}, fmt.Errorf(\"invalid image reference %q: empty repository\", ref)\n\t}\n\n\t// Official images live under library/ but are referenced without it.\n\tif registry == defaultRegistry && !strings.Contains(remainder, \"/\") {\n\t\tremainder = \"library/\" + remainder\n\t}\n\n\tif tag == \"\" && digest == \"\" {\n\t\ttag = defaultTag\n\t}\n\n\treturn Reference{\n\t\tRegistry:   registry,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/imagecheck/reference.go#L113-L149","documentation":"ParseReference splits the last ':' in the repository path as a tag separator (registry ports are stripped earlier). If the colon exists but nothing follows it, the tag is empty and this error is returned.","triggerScenarios":"Passing references ending in ':' such as \"nginx:\", \"repo:5000/app:\", or \"localhost:5000/foo:\".","commonSituations":"String templates that interpolate an empty tag variable (\"app:\" + version where version is \"\"), CLI/env config with a dangling colon, copy-paste errors where the tag was deleted.","solutions":["Remove the trailing ':' to use the implicit default tag (latest)","Supply an explicit tag, e.g. nginx:1.25","Fix the interpolation so the tag variable is set before building the reference"],"exampleFix":"// before\nref := fmt.Sprintf(\"nginx:%s\", os.Getenv(\"TAG\")) // TAG unset -> \"nginx:\"\n// after\ntag := os.Getenv(\"TAG\")\nif tag == \"\" { tag = \"latest\" }\nref := fmt.Sprintf(\"nginx:%s\", tag)","handlingStrategy":"validation","validationCode":"if strings.HasSuffix(ref, \":\") {\n    return fmt.Errorf(\"reference %q has an empty tag\", ref)\n}","typeGuard":"func hasTag(ref string) bool {\n    i := strings.LastIndex(ref, \":\")\n    return i != -1 && i < len(ref)-1 && !strings.Contains(ref[i+1:], \"/\")\n}","tryCatchPattern":"if _, err := imagecheck.ParseReference(ref); err != nil {\n    if strings.Contains(err.Error(), \"empty tag\") {\n        ref = strings.TrimSuffix(ref, \":\") // fall back to latest\n    }\n}","preventionTips":["Default empty tag variables to \"latest\" before interpolation","Never leave a dangling ':' at the end of an image string","Validate image references when accepting user config"],"tags":["image","reference-parsing","tag","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}