fix(scripts): opt fixture capture out of Node's Happy-Eyeballs connect#6505
Merged
Conversation
capture-fixtures.mjs pins DNS resolution by passing a custom `lookup`
callback straight to node:http/https's request options (SSRF/rebinding
guard). Node's dual-stack Happy-Eyeballs connect path (autoSelectFamily,
default-on since Node 20+) calls that callback with `{ all: true }` and
expects an array back; this callback only ever returns a single scalar
address, so the multi-connect path threw "Invalid IP address: undefined"
on every single request -- 0/598 fixtures captured in production.
Confirmed live: reproduced the exact TypeError against a known-healthy
target, fixed by disabling autoSelectFamily (this pinned single-address
lookup was never using the multi-attempt path anyway), verified the
same target then succeeds and a full dry-run run goes from 0% to ~72%
captured (remaining failures are legitimate: rate limits, non-JSON
content types, real upstream errors).
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6505 +/- ##
=======================================
Coverage 97.85% 97.85%
=======================================
Files 174 174
Lines 22196 22196
Branches 8798 8798
=======================================
Hits 21721 21721
Misses 81 81
Partials 394 394 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/capture-fixtures.mjs's DNS-pinninglookupcallback (SSRF/rebinding guard) only supports the old single-addressdns.lookupcallback signature.autoSelectFamily, default-on since Node 20+) calls customlookupcallbacks with{ all: true }and expects an array back -- this callback returns a scalar, so every request threwTypeError [ERR_INVALID_IP_ADDRESS]: Invalid IP address: undefined.capture-failedon 100% of candidates, which also brokeget_fixture/get_api_schemadownstream (both REST and MCP).safeFetchhelper inscripts/lib.mjs(used bysnapshot-openapi.mjsand others) was unaffected -- it goes through undici'sAgent/dispatcher, not node:http's rawlookupoption, and itscreatePinnedLookupalready handles both callback shapes.autoSelectFamily: falseon the request options -- this pinned single-address lookup never needed the multi-attempt path.Found during a full data-source audit following D1 retirement (unrelated to D1 -- pure Node runtime-behavior regression).
Test plan
TypeErrorlocally against a known-healthy target (apex.api.macrocosmos.ai)autoSelectFamily: falseresolves it against the same targetnode scripts/capture-fixtures.mjs --dry-run: went from 0/590 (0%) to ~420/590 (~72%) captured; all remaining failures are legitimate (429 rate limits, non-JSON content-type, real 404/422/502/503, oversized bodies, genuine timeouts) -- zeroTypeErrors remainnpx eslint/npx prettier --checkclean