{"record":{"id":"9ec365543e123ad5","repo":"helm/helm","slug":"invalid-oci-reference-w","errorCode":null,"errorMessage":"invalid OCI reference: %w","messagePattern":"invalid OCI reference: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/registry/plugin.go","lineNumber":187,"sourceCode":"\t\twithProv   bool\n\t}\n\n\t// PluginPullOption allows customizing plugin pull operations\n\tPluginPullOption func(*pluginPullOperation)\n)\n\n// PluginPullOptWithPluginName sets the plugin name for validation\nfunc PluginPullOptWithPluginName(name string) PluginPullOption {\n\treturn func(operation *pluginPullOperation) {\n\t\toperation.pluginName = name\n\t}\n}\n\n// GetPluginName extracts the plugin name from an OCI reference using proper reference parsing\nfunc GetPluginName(source string) (string, error) {\n\tref, err := newReference(source)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid OCI reference: %w\", err)\n\t}\n\n\t// Extract plugin name from the repository path\n\t// e.g., \"ghcr.io/user/plugin-name:v1.0.0\" -> Repository: \"user/plugin-name\"\n\trepository := ref.Repository\n\tif repository == \"\" {\n\t\treturn \"\", errors.New(\"invalid OCI reference: missing repository\")\n\t}\n\n\t// Get the last part of the repository path as the plugin name\n\tparts := strings.Split(repository, \"/\")\n\tpluginName := parts[len(parts)-1]\n\n\tif pluginName == \"\" {\n\t\treturn \"\", fmt.Errorf(\"invalid OCI reference: cannot determine plugin name from repository %s\", repository)\n\t}\n\n\treturn pluginName, nil","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/helm/helm/blob/2a29f1770b62844b27197d2507377361d45ad7c0/pkg/registry/plugin.go#L169-L205","documentation":"GetPluginName (pkg/registry/plugin.go) parses the source string with the OCI reference parser (newReference). If the string is not a well-formed registry/repository[:tag|@digest] reference, parsing fails and this error wraps the parser's specific reason.","triggerScenarios":"Calling GetPluginName, or `helm plugin install` from an oci:// source which derives the plugin name, with a malformed ref: missing registry host, a URL with a scheme like https://, whitespace, invalid tag characters, or a malformed digest reference.","commonSituations":"Passing https:// URLs where an OCI ref is expected; refs pasted with trailing whitespace or newlines; shell variables that are empty or still contain the oci:// prefix; invalid characters in the tag portion.","solutions":["Use a fully qualified OCI reference with no scheme: registry.example.com/namespace/plugin:1.0.0","Strip any oci:// prefix before passing the ref to registry package APIs","Quote refs in shell scripts to prevent word splitting and whitespace contamination","Read the wrapped error text - it states exactly which component of the reference is invalid"],"exampleFix":"// before\nname, err := registry.GetPluginName(\"https://ghcr.io/user/my-plugin:1.0.0\")\n\n// after\nref := strings.TrimPrefix(\"oci://ghcr.io/user/my-plugin:1.0.0\", \"oci://\")\nname, err := registry.GetPluginName(ref)","handlingStrategy":"validation","validationCode":"src := strings.TrimSpace(ref)\nsrc = strings.TrimPrefix(src, \"oci://\")\nif _, err := registry.ParseReference(src); err != nil { // github.com/oras-go/v2/registry\n\treturn fmt.Errorf(\"invalid OCI reference %q: %w\", ref, err)\n}","typeGuard":null,"tryCatchPattern":"name, err := registry.GetPluginName(source)\nif err != nil {\n\tif strings.Contains(err.Error(), \"invalid OCI reference\") {\n\t\t// surface the ref format problem to the user/config layer\n\t}\n\treturn err\n}","preventionTips":["Normalize refs before use: trim whitespace and strip oci:// prefixes","Always use fully qualified refs (registry/repo:tag or @digest) built from constants, not string surgery","Validate refs with oras-go's registry.ParseReference at the config/CLI boundary"],"tags":["oci","reference","validation","plugin"],"backgroundTag":null,"analyzedSha":"2a29f1770b62844b27197d2507377361d45ad7c0","analyzedAt":"2026-08-15T22:02:47.490Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}