Skip to content

Commit 232a2c8

Browse files
anandgupta42claude
andcommitted
fix(telemetry): cut the error line at the first non-ASCII character
Typographic quotes and other non-ASCII delimiters wrapped user content the ASCII quote handling did not see. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 19ed7d2 commit 232a2c8

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/opencode/src/altimate/telemetry/error-detail.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ const isCredential = (token: string) =>
6262
* that happen to spell a SQL statement are not recognised and can survive.
6363
*/
6464
// The line is cut at the token holding the first of: a credential stem (also inside quotes or a
65-
// compound key), a path separator, an escape, or a backtick-quoted span. Everything from there on is masked, because a
65+
// compound key), a path separator, an escape, a backtick, or any non-ASCII character (typographic quotes and the like). Everything from there on is masked, because a
6666
// value, path or escaped string can run on past whitespace and quote boundaries.
67-
const CUT = new RegExp(`${CREDENTIAL_STEMS.join("|")}|[\\\\/\x60]`, "i")
67+
const CUT = new RegExp(`${CREDENTIAL_STEMS.join("|")}|[\\\\/\x60]|[^\\x20-\\x7e]`, "i")
6868

6969
function cutAtUnsafe(line: string): string {
7070
const hit = CUT.exec(line)

‎packages/opencode/test/telemetry/error-detail.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ describe("templateErrorMessage", () => {
4545
["Authorization: Bearer secrettoken", "Authorization: <x>"],
4646
["bad api key hunter, retry", "bad api key <x>"],
4747
["unknown column `customer name` in field list", "unknown column <x>"],
48+
["bad value \u201cprivate customer phrase\u201d here", "bad value <x>"],
49+
["bad \u00abprivate phrase\u00bb here", "bad <x>"],
4850
["bad /Users/bob/proj/a.ts here", "bad <x>"],
4951
["bad C:\\Users\\bob\\a.ts here", "bad <x>"],
5052
[`bad ${pgUri} here`, "bad <x>"],

0 commit comments

Comments
 (0)