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

Function safeBodyText

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

Source from the content-addressed store, hash-verified

550 * not expect. The read is passed as a thunk so that `.clone()` throwing on an
551 * already-consumed body is caught here too, rather than escaping as a defect. */
552const safeBodyText = async (read: () => Promise<string>): Promise<string | null> =>
553 Promise.resolve()
554 .then(read)
555 .then(
556 (value) => value,
557 () => null,
558 );
559
560/** Structurally probe an untrusted upstream body. Returns `undefined` rather
561 * 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