From 078b179ee83e7b7e86b8e9d8fe7a30a0db9d8334 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 06:31:29 +0000 Subject: [PATCH] refactor: extract hasValidPrefix boolean in exception type extraction Replaces the duplicated condition logic in sendJobConclusionSpan with an explicit hasValidPrefix boolean. This removes the redundant colonIdx > 0 check in the exceptionMessage line (it was already implied by the exceptionType !== 'gh-aw.AgentError' test), and makes it immediately clear that both exceptionType and exceptionMessage derive from the same predicate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- actions/setup/js/send_otlp_span.cjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/actions/setup/js/send_otlp_span.cjs b/actions/setup/js/send_otlp_span.cjs index 8fa580feb05..810ecd05eef 100644 --- a/actions/setup/js/send_otlp_span.cjs +++ b/actions/setup/js/send_otlp_span.cjs @@ -785,8 +785,9 @@ async function sendJobConclusionSpan(spanName, options = {}) { // Extract colon-prefixed type when available ("push_to_pull_request_branch:...") const colonIdx = msg.indexOf(":"); const prefix = msg.slice(0, colonIdx); - const exceptionType = colonIdx > 0 && colonIdx < 64 && /^[a-z_][a-z0-9_.]*$/i.test(prefix) ? `gh-aw.${prefix.toLowerCase()}` : "gh-aw.AgentError"; - const exceptionMessage = (colonIdx > 0 && exceptionType !== "gh-aw.AgentError" ? msg.slice(colonIdx + 1).trim() : msg).slice(0, MAX_ATTR_VALUE_LENGTH); + const hasValidPrefix = colonIdx > 0 && colonIdx < 64 && /^[a-z_][a-z0-9_.]*$/i.test(prefix); + const exceptionType = hasValidPrefix ? `gh-aw.${prefix.toLowerCase()}` : "gh-aw.AgentError"; + const exceptionMessage = (hasValidPrefix ? msg.slice(colonIdx + 1).trim() : msg).slice(0, MAX_ATTR_VALUE_LENGTH); return { timeUnixNano: errorTimeNano, name: "exception",