fix(agent99): materialize credential target exit code
Some checks failed
CD Pipeline / select-latest-carrier (push) Successful in 45s
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m19s
CD Pipeline / revalidate-deploy-carrier (push) Successful in 43s
CD Pipeline / revalidate-post-deploy-carrier (push) Has been cancelled
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled

This commit is contained in:
Your Name
2026-07-22 14:37:46 +08:00
parent 1144ddee7d
commit 2ea038504d
2 changed files with 8 additions and 1 deletions

View File

@@ -73,12 +73,15 @@ function Invoke-FixedTargetProgram {
throw "target_timeout"
}
$process.WaitForExit() | Out-Null
$process.Refresh()
if (-not $process.HasExited) { throw "target_exit_state_unavailable" }
$exitCode = [int]$process.ExitCode
$stdout = if (Test-Path -LiteralPath $stdoutPath) {
([IO.File]::ReadAllText($stdoutPath, [Text.Encoding]::UTF8)).Trim()
} else { "" }
if ($stdout.Length -gt 8192) { throw "target_output_too_large" }
try { $result = $stdout | ConvertFrom-Json } catch { throw "target_receipt_invalid" }
if ($process.ExitCode -ne 0 -or [string]$result.terminal -eq "failed") {
if ($exitCode -ne 0 -or [string]$result.terminal -eq "failed") {
$code = if ($result.PSObject.Properties["error_code"]) { [string]$result.error_code } else { "target_failed" }
throw $code
}

View File

@@ -151,6 +151,10 @@ def test_agent99_entrypoint_is_fixed_and_never_transports_secret() -> None:
assert '$ExpectedWorkItemId = "P0-OBS-002"' in source
assert '$ExpectedRuntimeFileCount = 20' in source
assert '"sudo -n /usr/bin/python3 - --mode $($Mode.ToLowerInvariant())"' in source
assert "$process.Refresh()" in source
assert 'if (-not $process.HasExited) { throw "target_exit_state_unavailable" }' in source
assert "$exitCode = [int]$process.ExitCode" in source
assert '$exitCode -ne 0 -or [string]$result.terminal -eq "failed"' in source
assert "-RedirectStandardInput $TargetProgram" in source
assert "secret_in_transport = $false" in source
assert "Invoke-Expression" not in source