MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / safeBodyText

Function safeBodyText

packages/core/sdk/src/oauth-helpers.ts:519–525  ·  view source on GitHub ↗
(read: () => Promise<string>)

Source from the content-addressed store, hash-verified

517 * not expect. The read is passed as a thunk so that `.clone()` throwing on an
518 * already-consumed body is caught here too, rather than escaping as a defect. */
519const safeBodyText = async (read: () => Promise<string>): Promise<string | null> =>
520 Promise.resolve()
521 .then(read)
522 .then(
523 (value) => value,
524 () => null,
525 );
526
527/** Structurally probe an untrusted upstream body. Returns `undefined` rather
528 * than a fabricated value when it is not JSON; the caller's schema decode

Callers 4

safeJsonFromResponseFunction · 0.85
bodyPreviewFromResponseFunction · 0.85

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected