{"record":{"id":"55f473ebed7b6fb5","repo":"larksuite/cli","slug":"npm-registry-http-d","errorCode":null,"errorMessage":"npm registry: HTTP %d","messagePattern":"npm registry: HTTP (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/update/update.go","lineNumber":210,"sourceCode":"func FetchLatest() (string, error) {\n\treturn fetchLatestVersion()\n}\n\n// --- npm registry ---\n\ntype npmLatestResponse struct {\n\tVersion string `json:\"version\"`\n}\n\nfunc fetchLatestVersion() (string, error) {\n\tresp, err := httpClient().Get(registryURL)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"npm registry: HTTP %d\", resp.StatusCode)\n\t}\n\n\tbody, err := io.ReadAll(io.LimitReader(resp.Body, maxBody))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar result npmLatestResponse\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn \"\", err\n\t}\n\tif result.Version == \"\" {\n\t\treturn \"\", fmt.Errorf(\"npm registry: empty version\")\n\t}\n\treturn result.Version, nil\n}\n\n// --- semver helpers ---","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/update/update.go#L192-L228","documentation":"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.","triggerScenarios":"fetchLatestVersion receives a non-200 response from the npm registry; called via RefreshCache or FetchLatest when the update check runs.","commonSituations":"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.","solutions":["Retry the update check later; transient registry errors usually resolve on their own.","Check status of npmjs.org registry (status.npmjs.org) for outages.","Verify network/proxy configuration, especially corporate proxies that may return non-200 responses.","Check the embedded status code in the message: 4xx points at request/package issues, 5xx at registry-side issues.","Bypass the automatic update check (offline usage) and upgrade manually if the check blocks work."],"exampleFix":"// no caller code fix; handle the failure gracefully in tooling\n// before: update check failure aborts the command\n// after: log warning and continue\nif err := updater.RefreshCache(ctx); err != nil {\n    log.Printf(\"update check skipped: %v\", err)\n}","handlingStrategy":"retry","validationCode":"// no meaningful pre-check; optionally probe the registry first\nresp, err := http.Get(\"https://registry.npmjs.org/-/ping\")\nif err != nil || resp.StatusCode != http.StatusOK {\n    // skip update check\n}","typeGuard":null,"tryCatchPattern":"if err := updater.RefreshCache(ctx); err != nil {\n    if strings.Contains(err.Error(), \"npm registry: HTTP\") {\n        log.Printf(\"update check unavailable, skipping: %v\", err)\n        return nil // degrade gracefully\n    }\n    return err\n}","preventionTips":["Treat update checks as advisory; never fail the main command because of them.","Monitor npm registry status before batch operations.","Configure proxies to forward registry traffic correctly.","Back off and retry with jitter on 5xx/429 responses."],"tags":["network","http","update-check","npm-registry"],"backgroundTag":"http-non-200-response","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}