ipfs/kubo · error
parsing target version %q: %w
Error message
parsing target version %q: %w
What it means
The mirror case of error 445 in isNewerVersion: the TARGET version string passed to goversion.NewVersion is not a parseable version, so the comparison aborts with `parsing target version %q: %w`. The library wraps the underlying go-version parse error to show exactly which string failed.
Source
Thrown at core/commands/update.go:845
// normalizeVersion ensures a version string has a "v" prefix (for GitHub tags).
func normalizeVersion(s string) string {
s = strings.TrimSpace(s)
if !strings.HasPrefix(s, "v") {
return "v" + s
}
return s
}
// isNewerVersion returns true if target is newer than current.
func isNewerVersion(current, target string) (bool, error) {
cv, err := goversion.NewVersion(current)
if err != nil {
return false, fmt.Errorf("parsing current version %q: %w", current, err)
}
tv, err := goversion.NewVersion(target)
if err != nil {
return false, fmt.Errorf("parsing target version %q: %w", target, err)
}
return tv.GreaterThan(cv), nil
}
View on GitHub (pinned to 329838acdf)
Solutions
- Check the exact argument: run `ipfs update check` first and use a version exactly as listed (e.g. `v0.30.0`).
- Strip invalid characters / 'v' prefix / whitespace and trailing notes before retrying: target = strings.TrimPrefix(target, "v").
- If the target came from an API response, validate it with goversion.NewVersion before passing it on and surface a clearer message.
- Upgrade the kubo version so update.go fixes any stricter/looser parsing, or patch isNewerVersion to normalize the input.
Example fix
// before
newer, err := isNewerVersion(current, "latest") // unparseable
// after
target := strings.TrimPrefix(strings.TrimSpace(userInput), "v")
if _, perr := goversion.NewVersion(target); perr != nil {
return fmt.Errorf("invalid target version %q", userInput)
}
newer, err := isNewerVersion(current, target) Defensive patterns
Strategy: validation
Validate before calling
target = strings.TrimPrefix(strings.TrimSpace(target), "v")
if _, err := goversion.NewVersion(target); err != nil {
return fmt.Errorf("invalid target version %q", target)
} Type guard
func isParseableVersion(v string) bool {
_, err := goversion.NewVersion(v)
return err == nil
} Try / catch
newer, err := isNewerVersion(current, target)
if err != nil {
if strings.Contains(err.Error(), "parsing target version") {
return fmt.Errorf("%q is not a valid version; use one from `ipfs update check`", target)
}
return err
} Prevention
- Use `ipfs update check` output verbatim as the target version
- Normalize input: TrimSpace, TrimPrefix "v"
- Reject symbolic names like 'latest' before calling the updater
- Sanitize pasted text (strip whitespace, notes, URLs) before parsing
When it happens
Trigger: `ipfs update apply <version>` / `update check` invoked with a target that is empty, a tag like 'v' or 'latest-unparsed', contains spaces or invalid characters, or an API response produced a version field that is not semver-shaped.
Common situations: Typing a human label ('latest', 'stable') directly as the target version, copy-pasting a git tag with a 'v' prefix plus extra text, a mocked/test harness feeding bad strings, or a upstream release name that is not a plain semver.
Related errors
- parsing current version %q: %w
- supernode routing was never fully implemented and has been r
- unrecognized routing option: %s
- invalid configuration profile: %s
- command disabled: %v
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/386fd1243ad1b1d2.
Report an issue: GitHub.