{"record":{"id":"ac0c85e23a6f3550","repo":"hashicorp/nomad","slug":"plugin-provided-invalid-versions-v","errorCode":null,"errorMessage":"plugin provided invalid versions: %v","messagePattern":"plugin provided invalid versions: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/pluginutils/loader/init.go","lineNumber":183,"sourceCode":"\t}\n\n\treturn fingerprinted, nil\n}\n\n// selectApiVersion takes in PluginInfo and returns the highest compatable\n// version or an error if the plugins response is malformed. If there is no\n// overlap, an empty string is returned.\nfunc (l *PluginLoader) selectApiVersion(i *base.PluginInfoResponse) (string, error) {\n\tif i == nil {\n\t\treturn \"\", fmt.Errorf(\"nil plugin info given\")\n\t}\n\tif len(i.PluginApiVersions) == 0 {\n\t\treturn \"\", fmt.Errorf(\"plugin provided no compatible API versions\")\n\t}\n\n\tpluginVersions, err := convertVersions(i.PluginApiVersions)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"plugin provided invalid versions: %v\", err)\n\t}\n\n\t// Lookup the supported versions. These will be sorted highest to lowest\n\tsupportedVersions, ok := l.supportedVersions[i.Type]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unsupported plugin type %q\", i.Type)\n\t}\n\n\tfor _, sv := range supportedVersions {\n\t\tfor _, pv := range pluginVersions {\n\t\t\tif sv.Equal(pv) {\n\t\t\t\treturn pv.Original(), nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"\", nil\n}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/pluginutils/loader/init.go#L165-L201","documentation":"The plugin's declared PluginApiVersions strings are parsed with go-version via convertVersions. Any string that is not a valid version (e.g. \"\", \"one\", \"1.x\") aborts negotiation with this wrapped error.","triggerScenarios":"selectApiVersion calls convertVersions(i.PluginApiVersions) and version.NewVersion fails on one of the entries.","commonSituations":"Hand-written version strings like \"v1-alpha\" or \"1\" with stray characters; a plugin declaring \"latest\" or a protocol name instead of a semver.","solutions":["Use valid semver strings with an optional v prefix, e.g. \"v1.0.0\" or \"1.0.0\"","Check the wrapped %v for which entry failed to parse and correct it in the plugin","Add a quick local check version.NewVersion(v) in plugin tests to catch bad version constants"],"exampleFix":"// before\nPluginApiVersions: []string{\"csi-v1\"}\n// after\nPluginApiVersions: []string{\"v1.0.0\"}","handlingStrategy":"validation","validationCode":"for _, v := range info.PluginApiVersions {\n    if _, err := version.NewVersion(v); err != nil {\n        return fmt.Errorf(\"bad API version %q: %w\", v, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := loader.Init(...); err != nil {\n    if strings.Contains(err.Error(), \"plugin provided invalid versions\") {\n        // parse each PluginApiVersions entry with version.NewVersion to find the offender\n    }\n}","preventionTips":["Use plain semver strings (\"v1\", \"1.0.0\") with no prose or protocol names","Validate the version list with go-version in the plugin's tests","Keep API version strings as shared constants, not literals scattered in code"],"tags":["go","plugin-loader","version-parsing","nomad"],"backgroundTag":"invalid-version-string","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}