hashicorp/nomad · error
failed to convert version %q : %v
Error message
failed to convert version %q : %v
What it means
convertVersions maps a []string of version strings to []*version.Version (sorted highest first) using hashicorp/go-version. It fails fast on the first string version.NewVersion cannot parse, wrapping the underlying parse error.
Source
Thrown at helper/pluginutils/loader/init.go:210
for _, sv := range supportedVersions {
for _, pv := range pluginVersions {
if sv.Equal(pv) {
return pv.Original(), nil
}
}
}
return "", nil
}
// convertVersions takes a list of string versions and returns a sorted list of
// versions from highest to lowest.
func convertVersions(in []string) ([]*version.Version, error) {
converted := make([]*version.Version, len(in))
for i, v := range in {
vv, err := version.NewVersion(v)
if err != nil {
return nil, fmt.Errorf("failed to convert version %q : %v", v, err)
}
converted[i] = vv
}
sort.Slice(converted, func(i, j int) bool {
return converted[i].GreaterThan(converted[j])
})
return converted, nil
}
// scan scans the plugin directory and retrieves potentially eligible binaries
func (l *PluginLoader) scan() ([]os.FileInfo, error) {
if l.pluginDir == "" {
return nil, nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Correct the offending version string to valid semver (optional v prefix, numeric components)
- Inspect the wrapped %v to identify the exact string that failed
- Add a unit test that runs convertVersions (or version.NewVersion) over the declared version list
Example fix
// before
convertVersions([]string{"v1.", "v2"})
// after
convertVersions([]string{"v1.0.0", "v2.0.0"}) Defensive patterns
Strategy: validation
Validate before calling
vv, err := version.NewVersion(candidate)
if err != nil {
return fmt.Errorf("version %q rejected: %w", candidate, err)
} Try / catch
if err := loader.Init(...); err != nil {
if strings.Contains(err.Error(), "failed to convert version") {
// scan all version strings with version.NewVersion to locate the bad one
}
} Prevention
- Lint hardcoded version strings with a regex like ^v?\d+\.\d+\.\d+$
- Unit-test convertVersions on every declared version list
- Avoid building version strings via string concatenation of config values
When it happens
Trigger: Any of selectApiVersion, NewPluginLoader, or the internal anonymous helper passes a version string that go-version rejects (empty string, non-numeric, bad prerelease syntax).
Common situations: Hardcoded API version lists containing typos; environment/config-driven version strings interpolated incorrectly; using names like "v1" is fine but "v 1" or "1.0.0.0" is not.
Related errors
- failed to parse version %q for internal plugin %s: %v
- plugin provided invalid versions: %v
- PluginInfo info failed for internal plugin %s: %v
- failed to validate API versions %v for internal plugin %s: %
- failed to retrieve config schema for internal plugin %s: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/e4d99c07a83bacaa.
Report an issue: GitHub.