Files
OmniRoute/open-sse/executors/lmarena/error.ts
Diego Rodrigues de Sa e Souza 2fa6ef0bdd security(runtime): harden TLS provenance, lifecycle, and public error boundaries (#11742)
* security(deps): pin and verify tls-client native artifacts

* docs(changelog): link tls-client provenance PR

* security(runtime): harden TLS and public error boundaries

* security(runtime): resolve CodeQL error-boundary findings

* security(lmarena): close public stream error boundary

* fix(lmarena): normalize public error statuses

* chore(quality): rebaseline chatCore.ts for the surviving log-boundary hardening

open-sse/handlers/chatCore.ts 6219 -> 6287. This is the one part of #11742 that
survived the rebase: sanitizeErrorMessage on the plugin onError hook, on the
semaphore-timeout path and on failureMessage before it reaches console.log and
the call log, sanitizeUpstreamDetails on the malformed-response log, and
getSafeErrorMetadata + try/catch where hostile (Proxy) metadata could throw.

That is the LOG boundary, which is broader than Hard Rule #12 (responses). The
rest of the PR was dropped as already landed on the tip.
2026-09-17 15:35:35 -03:00

18 lines
628 B
TypeScript

import { sanitizeErrorMessage } from "../../utils/error.ts";
const ERROR_NAME_ONLY_RE = /^[A-Za-z]*Error:?$/;
/** Convert an unknown Arena failure into a stable, public-safe message. */
export function sanitizeLMArenaError(value: unknown, fallback = "Arena upstream error"): string {
let candidate = value;
try {
if (value instanceof Error) candidate = value.message;
} catch {
// Hostile thrown values can expose coercing prototype/message accessors.
}
const sanitized = sanitizeErrorMessage(candidate).trim();
if (!sanitized || ERROR_NAME_ONLY_RE.test(sanitized)) return fallback;
return sanitized;
}