Skip to content

Commit 5a85116

Browse files
committed
fix(openai): use truncateUtf16Safe for image gen log value truncation
One .slice(0, N) truncation site in the OpenAI image generation provider may cut UTF-16 surrogate pairs in half when the log value contains multi-byte characters such as emoji. Replace it with truncateUtf16Safe to keep the truncated output valid Unicode.
1 parent 3f2466c commit 5a85116

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

extensions/openai/image-generation-provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
sanitizeConfiguredModelProviderRequest,
3333
} from "openclaw/plugin-sdk/provider-http";
3434
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
35+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
3536
import {
3637
canonicalizeCodexResponsesBaseUrl,
3738
isOpenAICodexBaseUrl,
@@ -104,7 +105,7 @@ function sanitizeLogValue(value: unknown): string {
104105
return "unknown";
105106
}
106107
return cleaned.length > LOG_VALUE_MAX_CHARS
107-
? `${cleaned.slice(0, LOG_VALUE_MAX_CHARS)}...`
108+
? `${truncateUtf16Safe(cleaned, LOG_VALUE_MAX_CHARS)}...`
108109
: cleaned;
109110
}
110111

0 commit comments

Comments
 (0)