{"record":{"id":"bbc049ab9809ef0f","repo":"amir20/dozzle","slug":"invalid-image-reference-q-empty-repository","errorCode":null,"errorMessage":"invalid image reference %q: empty repository","messagePattern":"invalid image reference %q: empty repository","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/imagecheck/reference.go","lineNumber":136,"sourceCode":"\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,\n\t\tRepository: remainder,\n\t\tTag:        tag,\n\t\tDigest:     digest,\n\t}, nil\n}","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/imagecheck/reference.go#L118-L154","documentation":"After stripping the digest and tag, the remaining string is the repository. If it is empty (reference was just a registry, a tag, or ':'), ParseReference returns this error since a repository name is the minimum requirement for an image reference.","triggerScenarios":"Passing references like \":1.25\", \"localhost:5000\", \"localhost:5000:latest\", or \":\" where no repository path component exists after registry/tag extraction.","commonSituations":"Confusing registry endpoint with a full image name (passing only the registry host), parsing an image spec where the repo part was mistakenly consumed, or severely malformed config values.","solutions":["Include a repository path: registry host plus image name, e.g. localhost:5000/myapp:1.0","Do not pass a bare registry address where an image reference is expected","Split your config into registry + image fields and join them before parsing"],"exampleFix":"// before\ncheck(\"localhost:5000\") // treated as registry-only\n// after\ncheck(\"localhost:5000/myapp:1.0\")","handlingStrategy":"validation","validationCode":"parts := strings.SplitN(strings.TrimSuffix(strings.TrimSuffix(ref, \"@\"+digest), \":\"+tag), \"/\", 2)\nif len(parts) < 2 && !strings.Contains(ref, \".\") && !strings.Contains(ref, \"localhost\") {\n    // ensure a repository path exists\n}","typeGuard":"func hasRepository(ref string) bool {\n    base := ref\n    if i := strings.Index(base, \"@\"); i != -1 { base = base[:i] }\n    if i := strings.LastIndex(base, \":\"); i != -1 { base = base[:i] }\n    return base != \"\" && !strings.ContainsAny(base, \":\")\n}","tryCatchPattern":"if _, err := imagecheck.ParseReference(ref); err != nil {\n    if strings.Contains(err.Error(), \"empty repository\") {\n        return fmt.Errorf(\"got registry-only value %q; provide image name\", ref)\n    }\n    return err\n}","preventionTips":["Never pass a bare registry host where an image reference is expected","Keep registry and image name as separate config fields and join them","Include the image name in every reference: host[:port]/repo[:tag]"],"tags":["image","reference-parsing","repository","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"}