MCPcopy Create free account
hub / github.com/github/gh-aw / sampleResultIsError

Function sampleResultIsError

actions/setup/js/apply_samples.cjs:501–512  ·  view source on GitHub ↗

* Return true when an MCP tool-call result carries an application-level error * payload, regardless of whether the transport-level `isError` flag was set. * * Safe-output handlers encode errors as `{"result":"error", ...}` inside the * first content text item. This helper provides a defense-in-

(result)

Source from the content-addressed store, hash-verified

499 * @returns {boolean}
500 */
501function sampleResultIsError(result) {
502 if (!result) return false;
503 if (result.isError) return true;
504 const text = result.content && result.content[0] && result.content[0].text;
505 if (!text) return false;
506 try {
507 const parsed = JSON.parse(text);
508 return !!(parsed && parsed.result === "error");
509 } catch {
510 return false;
511 }
512}
513
514/**
515 * Append a synthetic terminal_reason: completed marker to the engine stdio log

Callers 2

mainFunction · 0.85

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected