{"record":{"id":"cba3272b5b4b6b98","repo":"docker/cli","slug":"failed-to-parse-repo-name-from-s-w","errorCode":null,"errorMessage":"failed to parse repo name from %s: %w","messagePattern":"failed to parse repo name from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/registryclient/client.go","lineNumber":125,"sourceCode":"\t\treturn \"\", err\n\t}\n\n\t_, opts, err := getManifestOptionsFromReference(ref)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdgst, err := manifestService.Put(ctx, manifest, opts...)\n\tif err != nil {\n\t\treturn dgst, fmt.Errorf(\"failed to put manifest %s: %w\", ref, err)\n\t}\n\treturn dgst, nil\n}\n\nfunc (c *client) getRepositoryForReference(ctx context.Context, ref reference.Named, repoEndpoint repositoryEndpoint) (distribution.Repository, error) {\n\trepoName, err := reference.WithName(repoEndpoint.repoName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse repo name from %s: %w\", ref, err)\n\t}\n\thttpTransport, err := c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint)\n\tif err != nil {\n\t\tif !strings.Contains(err.Error(), \"server gave HTTP response to HTTPS client\") {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !repoEndpoint.endpoint.TLSConfig.InsecureSkipVerify {\n\t\t\treturn nil, httpProtoError{cause: err}\n\t\t}\n\t\t// --insecure was set; fall back to plain HTTP\n\t\tif url := repoEndpoint.endpoint.URL; url != nil && url.Scheme == \"https\" {\n\t\t\turl.Scheme = \"http\"\n\t\t\thttpTransport, err = c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/internal/registryclient/client.go#L107-L143","documentation":"Thrown in getRepositoryForReference when reference.WithName(repoEndpoint.repoName) rejects the repository path extracted from your image reference. The repoName comes from reference.Path(reference.TrimNamed(ref)), so this means the path segment of the reference contains characters the Docker reference grammar forbids (uppercase letters, underscores in the wrong place, disallowed punctuation, over-long components). It indicates a malformed image name, not a network problem.","triggerScenarios":"Calling GetManifest / GetManifestList / MountBlob / PutManifest with a reference whose path is not a legal repository name — e.g. an uppercase component like \"MyApp/img\", a name containing illegal symbols, or a programmatically constructed ref that interpolates a slash-heavy or symbolic path.","commonSituations":"Typo'd image name with capitals; CI script building a ref from an env var containing uppercase branch names; custom registry namespace using characters the reference parser rejects; ref built by string concatenation instead of the reference package helpers.","solutions":["Inspect the %s value in the message to find which component has illegal characters and lowercase / sanitize it.","Validate the reference with reference.ParseNamed (or reference.WithName on the path) before calling any RegistryClient method.","Build references via reference.WithName / reference.ParseNamed rather than string concatenation so the grammar is enforced early.","Ensure each path component matches [a-z0-9]+(?:[._-][a-z0-9]+)* and is within length limits."],"exampleFix":"// before\nref, _ := reference.ParseNamed(\"MyApp/Image:1.0\")\nc.GetManifest(ctx, ref) // -> failed to parse repo name\n\n// after\nref, _ := reference.ParseNamed(\"myapp/image:1.0\")\nc.GetManifest(ctx, ref)","handlingStrategy":"validation","validationCode":"// Validate the reference before calling any RegistryClient method.\nfunc validRepoRef(s string) (reference.Named, error) {\n    ref, err := reference.ParseNamed(s)\n    if err != nil {\n        return nil, fmt.Errorf(\"invalid image reference %q: %w\", s, err)\n    }\n    // re-validate the path component the same way the client will\n    if _, err := reference.WithName(reference.Path(reference.TrimNamed(ref))); err != nil {\n        return nil, fmt.Errorf(\"invalid repository name in %q: %w\", s, err)\n    }\n    return ref, nil\n}","typeGuard":"// Confirm a reference carries a parseable repository path.\nfunc hasValidRepoName(ref reference.Named) bool {\n    _, err := reference.WithName(reference.Path(reference.TrimNamed(ref)))\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Build references with reference.ParseNamed / reference.WithName, never string concatenation.","Reject uppercase and disallowed characters in repository names at the input boundary.","Run a quick reference.WithName check in tests for any user-supplied image string."],"tags":["docker","registry","reference","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}