From 6c2a3fc32537ded687eceaa1e62287fd9124903c Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Sun, 28 Jun 2026 01:25:03 +0800 Subject: [PATCH] fix(ci): strip ANSI before matching TRACE in needs-logs bot The needs-logs workflow tested /\bTRACE\b/i against the raw issue body. Pasted terminal logs wrap the level in ANSI color codes (\x1b[90mTRACE\x1b[0m); the trailing 'm' of the color code abuts 'TRACE', so the leading \b never matches and a log that clearly contains TRACE is wrongly flagged needs-logs (e.g. #156). Strip ANSI escapes first, and measure the too-short heuristic on the cleaned text too. --- .github/workflows/issue-require-logs.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/issue-require-logs.yml b/.github/workflows/issue-require-logs.yml index 404916c8..84b1b2ef 100644 --- a/.github/workflows/issue-require-logs.yml +++ b/.github/workflows/issue-require-logs.yml @@ -31,10 +31,14 @@ jobs: const m = body.match(/###\s*TRACE 日志[^\n]*\n([\s\S]*?)(?:\n###\s|$)/); const section = (m ? m[1] : '').trim(); + // 粘贴的终端日志常带 ANSI 颜色码(如 \x1b[90mTRACE\x1b[0m), + // 颜色码结尾的 'm' 紧贴 TRACE 会吃掉 \b 单词边界,先剥掉再判定。 + const clean = section.replace(/\x1b\[[0-9;]*m/g, ''); + const empty = section === '' || /^_no response_$/i.test(section); - const hasTrace = /\bTRACE\b/i.test(section); + const hasTrace = /\bTRACE\b/i.test(clean); // 去掉代码围栏后过短,基本等于没给 - const stripped = section.replace(/```[a-z]*|```|`/gi, '').trim(); + const stripped = clean.replace(/```[a-z]*|```|`/gi, '').trim(); const tooShort = stripped.length < 40; const ok = !empty && hasTrace && !tooShort;