Skip to content

Commit 3b2807e

Browse files
appleboyCopilot
andauthored
Update util/api_key_helper_unix.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8548e44 commit 3b2807e

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

util/api_key_helper_unix.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,10 @@ func GetAPIKeyFromHelper(ctx context.Context, helperCmd string) (string, error)
7878

7979
// Wait for graceful termination with a grace period
8080
select {
81-
case err := <-done:
82-
if err != nil {
83-
return "", fmt.Errorf("api_key_helper terminated after timeout: %w", err)
84-
}
85-
apiKey := strings.TrimSpace(stdout.String())
86-
if apiKey == "" {
87-
return "", fmt.Errorf(
88-
"api_key_helper command returned empty output after timeout termination",
89-
)
90-
}
91-
return apiKey, nil
81+
case <-done:
82+
// Process exited after timeout was reached; treat as timeout regardless of exit status.
83+
// We intentionally ignore stdout/stderr here to avoid returning a key after a timeout.
84+
return "", fmt.Errorf("api_key_helper command timed out after %v", HelperTimeout)
9285

9386
case <-time.After(2 * time.Second):
9487
// Grace period expired: send SIGKILL to force termination

0 commit comments

Comments
 (0)