The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(windows): avoid locale-sensitive update timestamps
AlexMnrsca1b3f870596
diff --git a/scripts/desktop-update/windows.ps1 b/scripts/desktop-update/windows.ps1index 1c81bdf1146..40d51b3cd12 100644--- a/scripts/desktop-update/windows.ps1+++ b/scripts/desktop-update/windows.ps1@@ -421,7 +421,7 @@ function Write-Result([bool]$Ok, [int]$Code, [string]$Message, [bool]$ManualActimanual = $ManualActionmessage = $Messagebranch = $Branch- finished_at = [int][double]::Parse((Get-Date -UFormat %s), [System.Globalization.CultureInfo]::InvariantCulture)+ finished_at = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()} | ConvertTo-Json -Compress[System.IO.File]::WriteAllText($ResultPath, $obj)} catch {}@@ -611,7 +611,7 @@ try {# -- 0. Claim the update marker with OUR pid ---------------------------try {- $epoch = [int][double]::Parse((Get-Date -UFormat %s), [System.Globalization.CultureInfo]::InvariantCulture)+ $epoch = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()# WriteAllText for byte-exact LF framing: Set-Content emits CRLF and# the marker contract (Rust/TS/Python readers) is "<pid>\n<ts>\n".[System.IO.File]::WriteAllText($MarkerPath, "$PID`n$epoch`n")diff --git a/tests/test_desktop_update_windows_timestamp.py b/tests/test_desktop_update_windows_timestamp.pynew file mode 100644index 00000000000..5efd0cc04b4--- /dev/null+++ b/tests/test_desktop_update_windows_timestamp.py@@ -0,0 +1,34 @@+"""Regression tests for Windows desktop-update Unix timestamps.++PowerShell's ``Get-Date -UFormat %s`` is locale-sensitive. Under an ``es-ES``+culture it can produce a comma decimal separator, and parsing that string with+``InvariantCulture`` turns a ten-digit Unix timestamp plus fractional seconds+into a value too large for ``System.Int32``. The detached Windows updater must+use a locale-independent Unix timestamp API for both marker and result files.++The updater script is not executable on the Linux CI lane, so these tests lock+the source-level contract and reject the exact broken conversion.+"""++from __future__ import annotations++from pathlib import Path+++REPO_ROOT = Path(__file__).resolve().parent.parent+WINDOWS_UPDATE_PS1 = REPO_ROOT / "scripts" / "desktop-update" / "windows.ps1"+++def test_windows_update_uses_locale_independent_unix_seconds() -> None:+ source = WINDOWS_UPDATE_PS1.read_text(encoding="utf-8")+ safe_expression = "[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()"+ unsafe_expression = "[int][double]::Parse((Get-Date -UFormat %s)"++ assert source.count(safe_expression) == 2, (+ "windows.ps1 must use DateTimeOffset Unix seconds for both the "+ "update marker and the finished result timestamp"+ )+ assert unsafe_expression not in source, (+ "windows.ps1 must not parse locale-sensitive Get-Date -UFormat %s "+ "output through System.Int32"+ )