larksuite/cli · warning

npm registry: HTTP %d

Error message

npm registry: HTTP %d

What it means

fetchLatestVersion in internal/update queries the npm registry to learn the latest CLI version. When the registry responds with any HTTP status other than 200 OK, it throws this error embedding the status code. It indicates the update check itself failed at the transport level, not that the local CLI is broken.

Source

Thrown at internal/update/update.go:210

func FetchLatest() (string, error) {
	return fetchLatestVersion()
}

// --- npm registry ---

type npmLatestResponse struct {
	Version string `json:"version"`
}

func fetchLatestVersion() (string, error) {
	resp, err := httpClient().Get(registryURL)
	if err != nil {
		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 ---

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Retry the update check later; transient registry errors usually resolve on their own.
  2. Check status of npmjs.org registry (status.npmjs.org) for outages.
  3. Verify network/proxy configuration, especially corporate proxies that may return non-200 responses.
  4. Check the embedded status code in the message: 4xx points at request/package issues, 5xx at registry-side issues.
  5. Bypass the automatic update check (offline usage) and upgrade manually if the check blocks work.

Example fix

// no caller code fix; handle the failure gracefully in tooling
// before: update check failure aborts the command
// after: log warning and continue
if err := updater.RefreshCache(ctx); err != nil {
    log.Printf("update check skipped: %v", err)
}
Defensive patterns

Strategy: retry

Validate before calling

// no meaningful pre-check; optionally probe the registry first
resp, err := http.Get("https://registry.npmjs.org/-/ping")
if err != nil || resp.StatusCode != http.StatusOK {
    // skip update check
}

Try / catch

if err := updater.RefreshCache(ctx); err != nil {
    if strings.Contains(err.Error(), "npm registry: HTTP") {
        log.Printf("update check unavailable, skipping: %v", err)
        return nil // degrade gracefully
    }
    return err
}

Prevention

When it happens

Trigger: fetchLatestVersion receives a non-200 response from the npm registry; called via RefreshCache or FetchLatest when the update check runs.

Common situations: npm registry outage or partial degradation (5xx), rate limiting (429), registry returning 404 for a package name, corporate proxies/firewalls returning error pages, or stale DNS/CDN issues.

Related errors


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