mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-20 05:42:19 +03:00
* 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.
18 lines
628 B
TypeScript
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;
|
|
}
|