larksuite/cli · error
empty version
Error message
empty version
What it means
parseSemverPrefix validates a version string like "1.2.3" used for RequiredCLIVersion comparison. It throws "empty version" when, after trimming whitespace and a leading "v", the string is empty. This guard exists so an empty RequiredCLIVersion never silently passes validation or compares as all-zero.
Source
Thrown at internal/platform/version.go:115
case strings.HasPrefix(s, "<="):
return "<=", strings.TrimSpace(s[2:])
case strings.HasPrefix(s, ">"):
return ">", strings.TrimSpace(s[1:])
case strings.HasPrefix(s, "<"):
return "<", strings.TrimSpace(s[1:])
case strings.HasPrefix(s, "="):
return "=", strings.TrimSpace(s[1:])
default:
return "", s
}
}
// parseSemverPrefix parses MAJOR[.MINOR[.PATCH]] and drops any pre-release /
// build suffix. Missing minor / patch default to 0. Accepts a leading "v".
func parseSemverPrefix(s string) (parts [3]int, err error) {
s = strings.TrimPrefix(strings.TrimSpace(s), "v")
if s == "" {
return parts, fmt.Errorf("empty version")
}
// Trim pre-release/build suffix at first '-' or '+'.
for i, c := range s {
if c == '-' || c == '+' {
s = s[:i]
break
}
}
fields := strings.Split(s, ".")
// Reject `1.2.3.4` and longer instead of silently truncating —
// truncation hides the typo and lets a malformed RequiredCLIVersion
// pass validation while the comparator below operates on the wrong
// components. Build-version parsing has its own fail-open guard
// upstream (see satisfiesRequiredCLIVersion comment about exotic
// build tags), so it stays compatible.
if len(fields) > 3 {
return [3]int{}, fmt.Errorf("version %q has more than three numeric components", s)
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Set RequiredCLIVersion to a concrete MAJOR[.MINOR[.PATCH]] value, e.g. "1.2" or "2.0.3".
- If the version is optional in your config, omit the field entirely rather than setting it to an empty string.
- Check where the version value originates (registry meta, env var, config file) for a truncation or placeholder left blank.
Example fix
// before requiredCLIVersion = "" // after requiredCLIVersion = "1.2.0"
Defensive patterns
Strategy: validation
Validate before calling
func validRequiredCLIVersion(s string) bool {
t := strings.TrimSpace(strings.TrimPrefix(s, "v"))
return t != ""
}
// guard: if !validRequiredCLIVersion(cfg.RequiredCLIVersion) { fix config before calling } Type guard
func hasVersion(s string) bool { return strings.TrimSpace(strings.TrimPrefix(s, "v")) != "" } Try / catch
parts, err := parseSemverPrefix(v)
if err != nil {
// err.Error() == "empty version": skip or prompt for a concrete version
return fmt.Errorf("invalid RequiredCLIVersion %q: %w", v, err)
} Prevention
- Never set RequiredCLIVersion to ""; omit the field if not needed.
- Validate config at load time and fail fast on blank version fields.
- Add a schema/config test asserting a non-empty version string.
When it happens
Trigger: Calling satisfiesRequiredCLIVersion with a configured RequiredCLIVersion that is empty or only whitespace ("", " ", "v"), after TrimPrefix/TrimSpace leaves nothing to parse.
Common situations: Config/registry metadata with a missing or blank required_cli_version field; a build/release pipeline that wrote an empty value; hand-edited config where the version was deleted.
Related errors
- version %q has more than three numeric components
- non-numeric component %q in version %q
- Invalid column: {column!r}
- Invalid column index: {index}
- anchor outside sheet: {position!r}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/b9644c5694957577.
Report an issue: GitHub.