larksuite/cli · error

version %q has more than three numeric components

Error message

version %q has more than three numeric components

What it means

parseSemverPrefix accepts at most MAJOR.MINOR.PATCH. It throws this error when a version string splits into more than three dot-separated numeric fields. The fail-closed guard prevents a malformed RequiredCLIVersion from passing validation while the comparator operates on truncated (wrong) components.

Source

Thrown at internal/platform/version.go:132

	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)
	}
	for i, f := range fields {
		n, err := strconv.Atoi(strings.TrimSpace(f))
		if err != nil || n < 0 {
			return [3]int{}, fmt.Errorf("non-numeric component %q in version %q", f, s)
		}
		parts[i] = n
	}
	return parts, nil
}

func compareSemver(a, b [3]int) int {
	for i := 0; i < 3; i++ {
		if a[i] < b[i] {
			return -1
		}
		if a[i] > b[i] {
			return 1

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Trim the version to three components: "1.2.3.4" -> "1.2.3".
  2. Express build metadata with '-' or '+' instead of extra dot components, e.g. "1.2.3-beta.1".
  3. Verify the RequiredCLIVersion source; a release script may be emitting an internal multi-part build number.

Example fix

// before
requiredCLIVersion = "1.2.3.4"
// after
requiredCLIVersion = "1.2.3"
Defensive patterns

Strategy: validation

Validate before calling

func isThreePartVersion(s string) bool {
	s = strings.TrimPrefix(strings.TrimSpace(s), "v")
	if i := strings.IndexAny(s, "-+"); i >= 0 { s = s[:i] }
	return len(strings.Split(s, ".")) <= 3 && s != ""
}

Type guard

func isSemverPrefix(s string) bool { parts := strings.Split(s, "."); return len(parts) >= 1 && len(parts) <= 3 }

Try / catch

parts, err := parseSemverPrefix(v)
if err != nil {
	if strings.Contains(err.Error(), "more than three numeric components") {
		// trim to first three components or surface a config error
	}
	return err
}

Prevention

When it happens

Trigger: Calling satisfiesRequiredCLIVersion with a version like "1.2.3.4" or "1.2.3.0.1" (more than 3 dot-separated components).

Common situations: Copying a four-part version from another tool (e.g. Windows-style file versions); typos with extra dots; pasting a full build string with dotted suffixes into the config.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/002a5c535d3ecfea. Report an issue: GitHub.