{"record":{"id":"47e6fdc735649eb7","repo":"GoogleContainerTools/skaffold","slug":"parsing-reference-q-w","errorCode":null,"errorMessage":"parsing reference %q: %w","messagePattern":"parsing reference %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/docker/remote.go","lineNumber":170,"sourceCode":"\n// IsInsecure tests if an image is pulled from an insecure registry; default is false\nfunc IsInsecure(ref name.Reference, insecureRegistries map[string]bool) bool {\n\treturn insecureRegistries[ref.Context().Registry.Name()]\n}\n\n// insecureTransportOption allows untrusted certificates.\nfunc insecureTransportOption() remote.Option {\n\ttransport := remote.DefaultTransport.(*http.Transport).Clone()\n\ttransport.TLSClientConfig = &tls.Config{\n\t\tInsecureSkipVerify: true, //nolint: gosec\n\t}\n\treturn remote.WithTransport(transport)\n}\n\nfunc parseReference(s string, cfg Config, opts ...name.Option) (name.Reference, error) {\n\tref, err := name.ParseReference(s, opts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing reference %q: %w\", s, err)\n\t}\n\n\tif IsInsecure(ref, cfg.GetInsecureRegistries()) {\n\t\tref, err = name.ParseReference(s, name.Insecure)\n\t\tif err != nil {\n\t\t\tlog.Entry(context.TODO()).Warnf(\"error getting insecure registry: %s\\nremote references may not be retrieved\", err.Error())\n\t\t}\n\t}\n\n\treturn ref, nil\n}\n\ntype digester interface {\n\tDigest() (v1.Hash, error)\n}\n\nfunc digest(d digester) (string, error) {\n\th, err := d.Digest()","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/remote.go#L152-L188","documentation":"parseReference wraps go-containerregistry's name.ParseReference failure as \"parsing reference %q\". It is the shared entry point used by AddRemoteTag, getRemoteImage, and getRemoteIndex, so any malformed image reference anywhere in the remote-image flow surfaces through this error.","triggerScenarios":"An image string passed to any remote lookup fails name.ParseReference: empty string, uppercase characters, invalid registry/repotag syntax, scheme prefix, or (in the insecure re-parse path) a reference that still fails validation with name.Insecure.","commonSituations":"Templated image names left unresolved (\"{{.IMAGE}}\"); uppercase repo names; trailing whitespace or newlines from env vars; fully-qualified URLs with scheme; malformed digests (\"@sha256:xyz\" truncated).","solutions":["Print/log the reference exactly as passed (it's quoted with %q to expose whitespace/empties).","Validate the string: lowercase alphanumerics, optional registry host, optional :tag or @sha256:digest — test with `crane digest <ref>` locally.","Strip scheme prefixes and trim whitespace before calling.","Ensure image name templates/values resolve before invoking Skaffold commands.","Use fully-qualified names consistently (registry/repo:tag) to avoid ambiguity errors."],"exampleFix":"// before\nimage := os.Getenv(\"IMAGE\") // \" GCR.io/Proj/App \"\nidx, err := docker.RetrieveRemoteConfig(image, ...)\n// after\nimage = strings.ToLower(strings.TrimSpace(os.Getenv(\"IMAGE\")))\nif image == \"\" { return errors.New(\"IMAGE env var not set\") }\nidx, err := docker.RetrieveRemoteConfig(image, ...)","handlingStrategy":"validation","validationCode":"func validateImageRef(s string) error {\n\ts = strings.ToLower(strings.TrimSpace(s))\n\ts = strings.TrimPrefix(strings.TrimPrefix(s, \"https://\"), \"http://\")\n\tif s == \"\" { return errors.New(\"empty image reference\") }\n\t_, err := name.ParseReference(s, name.WeakValidation)\n\treturn err\n}","typeGuard":"func isParsableReference(s string) bool {\n\t_, err := name.ParseReference(strings.TrimSpace(s), name.WeakValidation)\n\treturn err == nil\n}","tryCatchPattern":"if err := validateImageRef(image); err != nil { return err }\nif _, err := docker.RetrieveRemoteConfig(image, cfg, platform); err != nil {\n\tif strings.Contains(err.Error(), \"parsing reference\") {\n\t\treturn fmt.Errorf(\"image ref %q malformed: use [registry/]repo[:tag|@digest], lowercase, no scheme\", image)\n\t}\n\treturn err\n}","preventionTips":["Normalize references: trim whitespace, lowercase, strip scheme, before every registry call.","Fail fast on empty/unresolved template variables.","Use fully-qualified references (registry/repo:tag) to avoid default-registry ambiguity.","Add a unit test that round-trips all configured image names through name.ParseReference."],"tags":["docker","validation","image-reference","naming"],"backgroundTag":"invalid-image-reference","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}