(
options: PerformRequestOptions,
testInfo: { file: string; line?: number } | undefined,
workDir: string,
toolResultNormalizers: ToolResultNormalizer[],
storedData?: NormalizedData,
)
| 586 | } |
| 587 | |
| 588 | async function exitWithNoMatchingRequestError( |
| 589 | options: PerformRequestOptions, |
| 590 | testInfo: { file: string; line?: number } | undefined, |
| 591 | workDir: string, |
| 592 | toolResultNormalizers: ToolResultNormalizer[], |
| 593 | storedData?: NormalizedData, |
| 594 | ) { |
| 595 | let diagnostics: string; |
| 596 | try { |
| 597 | const normalized = await parseAndNormalizeRequest( |
| 598 | options.body, |
| 599 | workDir, |
| 600 | toolResultNormalizers, |
| 601 | ); |
| 602 | const requestMessages = normalized.conversations[0]?.messages ?? []; |
| 603 | |
| 604 | let rawMessages: unknown[] = []; |
| 605 | try { |
| 606 | rawMessages = |
| 607 | (JSON.parse(options.body ?? "{}") as { messages?: unknown[] }) |
| 608 | .messages ?? []; |
| 609 | } catch { |
| 610 | /* non-JSON body */ |
| 611 | } |
| 612 | |
| 613 | diagnostics = diagnoseMatchFailure( |
| 614 | requestMessages, |
| 615 | rawMessages, |
| 616 | storedData, |
| 617 | ); |
| 618 | } catch (e) { |
| 619 | diagnostics = `(unable to parse request for diagnostics: ${e})`; |
| 620 | } |
| 621 | |
| 622 | const errorMessage = `No cached response found for ${options.requestOptions.method} ${options.requestOptions.path}.\n${diagnostics}`; |
| 623 | |
| 624 | // Format as GitHub Actions annotation when test location is available |
| 625 | const annotation = [ |
| 626 | testInfo?.file ? `file=${testInfo.file}` : "", |
| 627 | typeof testInfo?.line === "number" ? `line=${testInfo.line}` : "", |
| 628 | ] |
| 629 | .filter(Boolean) |
| 630 | .join(","); |
| 631 | process.stderr.write( |
| 632 | `::error${annotation ? ` ${annotation}` : ""}::${errorMessage}\n`, |
| 633 | ); |
| 634 | |
| 635 | options.onError(new Error(errorMessage)); |
| 636 | } |
| 637 | |
| 638 | async function findSavedChatCompletionResponse( |
| 639 | storedData: NormalizedData, |
no test coverage detected
searching dependent graphs…