larksuite/cli · warning
npm registry: empty version
Error message
npm registry: empty version
What it means
After a successful HTTP 200 fetch from the npm registry, the JSON body is unmarshaled into npmLatestResponse. If the dist-tags.latest version field is missing or empty, this error is thrown rather than proceeding with a blank version. It guards against corrupted or schema-changed registry responses being treated as a valid latest version.
Source
Thrown at internal/update/update.go:223
return "", err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("npm registry: HTTP %d", resp.StatusCode)
}
body, err := io.ReadAll(io.LimitReader(resp.Body, maxBody))
if err != nil {
return "", err
}
var result npmLatestResponse
if err := json.Unmarshal(body, &result); err != nil {
return "", err
}
if result.Version == "" {
return "", fmt.Errorf("npm registry: empty version")
}
return result.Version, nil
}
// --- semver helpers ---
// IsNewer returns true if version a should be considered an update over b.
//
// When both parse as semver, standard comparison applies.
// When b cannot be parsed (e.g. bare commit hash "9b933f1"), any valid a
// is considered newer — an unparseable local version is assumed outdated.
// When a cannot be parsed, returns false (can't confirm it's newer).
func IsNewer(a, b string) bool {
ap := parseVersionDetail(a)
bp := parseVersionDetail(b)
if ap == nil {
return false // can't confirm remote is newer
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Retry the update check; the response may have been transiently malformed.
- Verify any configured npm registry/mirror is the correct package metadata endpoint.
- Clear caches/interceptors that might serve stale JSON instead of the registry response.
- If persistent, report the issue; the CLI falls back to using the current version.
Defensive patterns
Strategy: fallback
Validate before calling
// pre-validate expected registry response shape when fetching manually
var probe struct {
Version string `json:"version"`
}
if json.Unmarshal(body, &probe) == nil && probe.Version == "" {
// treat as invalid registry response; use fallback
} Try / catch
ver, err := updater.FetchLatest(ctx)
if err != nil {
log.Printf("latest-version lookup failed, assuming current: %v", err)
ver = currentVersion
} Prevention
- Avoid custom npm mirrors/registries for the CLI's update channel unless they mirror the exact metadata endpoint.
- Cache the last known-good version and fall back to it on parse failures.
- Alert on repeated empty-version responses — usually a proxy or schema issue.
- Pin the update channel to the official registry when behind intercepting proxies.
When it happens
Trigger: npm registry returns HTTP 200 with a JSON body whose 'version' (dist-tags.latest) field is absent or empty string, during RefreshCache or FetchLatest.
Common situations: Registry-side schema changes, intermediate proxies/CDNs returning a valid-JSON page that is not the package metadata, cached error payloads, or mirror/registry misconfiguration (e.g. custom npm registry pointing at the wrong path).
Related errors
- failed to parse user info: %w
- npm registry: HTTP %d
- check failed: %s
- lark-cli stdout was not JSON: {snippet}
- lark-cli returned a non-object JSON payload
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/b4af4e290fc0d285.
Report an issue: GitHub.