fix(scripts): preserve emoji in request log previews (#109481)

* fix(scripts): preserve emoji in request log previews

* fix(scripts): keep mock preview standalone

* refactor(scripts): reuse UTF-16 truncation helper

Co-authored-by: Leon-SK668 <0668001470@xydigit.com>

* test(scripts): cover raw Node mock loading

Co-authored-by: Leon-SK668 <0668001470@xydigit.com>

* docs(scripts): note raw Node type stripping contract

Co-authored-by: Leon-SK668 <0668001470@xydigit.com>

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
Leon-SK668
2026-07-17 09:49:36 +08:00
committed by GitHub
parent 067635cb51
commit 1f5c8239d7
2 changed files with 29 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
// Mock OpenAI-compatible HTTP server helpers for E2E scenarios.
import fs from "node:fs";
// Raw launchers meet the repo's Node 22.22.3 minimum, where native TS stripping is enabled.
import { truncateUtf16Safe } from "../../../packages/normalization-core/src/utf16-slice.ts";
import { readPositiveIntEnv } from "./env-limits.mjs";
const DEFAULT_REQUEST_MAX_BYTES = 4 * 1024 * 1024;
@@ -76,7 +78,7 @@ export function boundedRequestLogBody(value, bodyText, limits = readMockOpenAiHt
return {
truncated: true,
byteLength,
preview: bodyText.slice(0, REQUEST_LOG_PREVIEW_CHARS),
preview: truncateUtf16Safe(bodyText, REQUEST_LOG_PREVIEW_CHARS),
};
}