Fixed IndexNow status-code detection (429/422/403 mislabelled as ping_failed)#28407
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe IndexNow ping service's error-handling logic was refactored to robustly extract the HTTP status code from multiple error shapes ( Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
IndexNow failures keyed off err.statusCode, but got's HTTPError exposes the status at err.response.statusCode, so 429/422/403 fell through to the generic indexnow.ping_failed branch (logged with status_code: null) - hiding rate limiting and key problems. Derive the status from both shapes (err.statusCode ?? err.response?.statusCode) and classify: 429 rate_limited; 422/403 key_validation_failed; else ping_failed. Tests exercise the real got HTTPError shape so they cover the production path.
5624453 to
feb533f
Compare
Summary
IndexNow failures were mis-detecting the HTTP status code, so rate-limits (429) and key-validation errors (422/403) were silently mislabelled as the generic
indexnow.ping_failed(withstatus_code: null).The classification in the
ping()catch block keyed offerr.statusCode, but for a non-2xx responsegotthrows anHTTPErrorwhose status lives aterr.response.statusCode, noterr.statusCode. So in production those branches never matched and every 429/422/403 fell through to the generic failure branch — making rate-limiting and key problems invisible in our structured logs.Changes
HTTPError(status onerr.response.statusCode) and the existing manual unexpected-2xx throw (status onerr.statusCode).statusCode:429 → indexnow.rate_limited;422/403 → indexnow.key_validation_failed(403 = key not valid / key file not found — the same class of problem as 422); everything else →indexnow.ping_failed. Log the realhttp.response.status_code.HTTPErrorshape (status only onerr.response.statusCode) covering 429 / 422 / 403 / 503, plus the manual-throw shape. These would have caught the original bug (the previous nock-based tests passed only because the request library happens to flattenstatusCodeonto the error in some versions).No behavioural change to pinging itself — this is observability only (correct event names + status codes).
Test
pnpm test:single test/unit/server/services/indexnow.test.js— 27 passing.