Skip to content

Commit 40bfeac

Browse files
committed
feat: Enhance whitespace detection in token validation
Shows detailed information when whitespace is detected: - Token length - Position of whitespace character - Type of whitespace (newline, space, tab, etc) This helps quickly identify malformed token secrets.
1 parent e496fa7 commit 40bfeac

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

updater/action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,19 @@ runs:
128128
}
129129
130130
if ($env:GH_TOKEN -match '\s') {
131-
Write-Output "::error::GitHub token contains whitespace characters (newlines, spaces, etc). This suggests the token secret may be malformed."
131+
$tokenLength = $env:GH_TOKEN.Length
132+
$whitespaceMatch = [regex]::Match($env:GH_TOKEN, '\s')
133+
$position = $whitespaceMatch.Index
134+
$char = $whitespaceMatch.Value
135+
$charName = switch ($char) {
136+
"`n" { "newline (LF)" }
137+
"`r" { "carriage return (CR)" }
138+
"`t" { "tab" }
139+
" " { "space" }
140+
default { "whitespace character (code: $([int][char]$char))" }
141+
}
142+
Write-Output "::error::GitHub token contains whitespace at position $position of $tokenLength characters: $charName"
143+
Write-Output "::error::This suggests the token secret may be malformed. Check for extra newlines when setting the secret."
132144
exit 1
133145
}
134146

0 commit comments

Comments
 (0)