Skip to content

Commit a7bd203

Browse files
refactor: extract hasValidPrefix boolean in exception type extraction (#25989)
1 parent 8298105 commit a7bd203

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

actions/setup/js/send_otlp_span.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,9 @@ async function sendJobConclusionSpan(spanName, options = {}) {
785785
// Extract colon-prefixed type when available ("push_to_pull_request_branch:...")
786786
const colonIdx = msg.indexOf(":");
787787
const prefix = msg.slice(0, colonIdx);
788-
const exceptionType = colonIdx > 0 && colonIdx < 64 && /^[a-z_][a-z0-9_.]*$/i.test(prefix) ? `gh-aw.${prefix.toLowerCase()}` : "gh-aw.AgentError";
789-
const exceptionMessage = (colonIdx > 0 && exceptionType !== "gh-aw.AgentError" ? msg.slice(colonIdx + 1).trim() : msg).slice(0, MAX_ATTR_VALUE_LENGTH);
788+
const hasValidPrefix = colonIdx > 0 && colonIdx < 64 && /^[a-z_][a-z0-9_.]*$/i.test(prefix);
789+
const exceptionType = hasValidPrefix ? `gh-aw.${prefix.toLowerCase()}` : "gh-aw.AgentError";
790+
const exceptionMessage = (hasValidPrefix ? msg.slice(colonIdx + 1).trim() : msg).slice(0, MAX_ATTR_VALUE_LENGTH);
790791
return {
791792
timeUnixNano: errorTimeNano,
792793
name: "exception",

0 commit comments

Comments
 (0)