larksuite/cli · error

non-numeric component %q in version %q

Error message

non-numeric component %q in version %q

What it means

Each dot-separated component of the version must parse via strconv.Atoi as a non-negative integer. This error is thrown when a component is not numeric, e.g. "1.x.3". Pre-release/build suffixes must be attached with '-' or '+' so they are trimmed before splitting, not placed after a dot.

Source

Thrown at internal/platform/version.go:137

		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
		}
	}
	return 0
}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Use only digits in each dot-separated component; express pre-releases with a dash: "1.2.3-rc1", not "1.2.3.rc1".
  2. Fix typos or stray characters in the version string.
  3. If the value comes from registry meta or env, re-fetch/regenerate it to overwrite the corrupted entry.

Example fix

// before
requiredCLIVersion = "1.2.3.rc1"
// after
requiredCLIVersion = "1.2.3-rc1"
Defensive patterns

Strategy: validation

Validate before calling

func numericComponents(s string) bool {
	s = strings.TrimPrefix(strings.TrimSpace(s), "v")
	if i := strings.IndexAny(s, "-+"); i >= 0 { s = s[:i] }
	for _, f := range strings.Split(s, ".") {
		if _, err := strconv.Atoi(f); err != nil { return false }
	}
	return true
}

Type guard

func isPlainSemver(s string) bool { m, _ := regexp.MatchString(`^v?\d+(\.\d+){0,2}(-[^+]+)?(\+.*)?$`, s); return m }

Try / catch

parts, err := parseSemverPrefix(v)
if err != nil {
	var msg string
	if _, aerr := strconv.Atoi(v); aerr != nil { msg = "non-numeric version component" }
	return fmt.Errorf("%s: %w", msg, err)
}

Prevention

When it happens

Trigger: Calling satisfiesRequiredCLIVersion with versions like "1.beta", "1..2" (empty component), "1.2.3.rc1" (suffix after a dot instead of a dash), or strings containing stray letters/spaces.

Common situations: Writing pre-release tags after dots instead of dashes; typos like 'O' vs '0'; copy-paste including units or labels like "1.2.3 LTS"; corrupted config values.

Related errors


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