MCPcopy Index your code
hub / github.com/coder/coder / SanitizeLogOutput

Function SanitizeLogOutput

codersdk/agentsdk/logs_sanitize.go:8–11  ·  view source on GitHub ↗

SanitizeLogOutput replaces invalid UTF-8 and NUL characters in log output. Invalid UTF-8 cannot be transported in protobuf string fields, and PostgreSQL rejects NUL bytes in text columns.

(s string)

Source from the content-addressed store, hash-verified

6// Invalid UTF-8 cannot be transported in protobuf string fields, and PostgreSQL
7// rejects NUL bytes in text columns.
8func SanitizeLogOutput(s string) string {
9 s = strings.ToValidUTF8(s, "❌")
10 return strings.ReplaceAll(s, "\x00", "❌")
11}

Callers 6

TestWorkspaceAgentLogsFunction · 0.92
BatchCreateLogsMethod · 0.92
TestBatchCreateLogsFunction · 0.92
TestSanitizeLogOutputFunction · 0.92
ProtoFromLogFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestWorkspaceAgentLogsFunction · 0.74
TestBatchCreateLogsFunction · 0.74
TestSanitizeLogOutputFunction · 0.74