fix: propagate curl exit code through pipe with set -o pipefail#1159
Open
qozle wants to merge 1 commit intoanthropics:mainfrom
Open
fix: propagate curl exit code through pipe with set -o pipefail#1159qozle wants to merge 1 commit intoanthropics:mainfrom
qozle wants to merge 1 commit intoanthropics:mainfrom
Conversation
When curl returns 429/403, the install silently succeeds because POSIX pipe exit = last command (bash), not curl. The 3-attempt retry loop never fired on rate-limit or auth errors. Changes: - Prefix bash command with set -o pipefail to propagate curl errors - Validate claudeCodeVersion format before interpolating into shell - Hoist homeBin above loop; verify binary exists post-install - Log the actual error on failed attempts instead of generic message Fixes anthropics#1136 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
installClaudeCode()runs a bash command that pipes the install script output.Because of POSIX pipe semantics, the exit code of this pipeline is the exit code of the last command (
bash), notcurl. When curl returns HTTP 429 (rate-limited) or 403 (auth error), it exits non-zero — butbashreceives an empty or partial script and exits 0. The caller sees success, the retry loop never fires, and Claude Code is not actually installed.Fix
Four targeted changes to
installClaudeCode()insrc/entrypoints/run.ts:set -o pipefail— prefixed to the bash command so any non-zero exit anywhere in the pipeline propagates to the process exit code. Curl 429/403 now correctly fails the install attempt.Version regex guard — validate
claudeCodeVersionagainst/^\d+\.\d+\.\d+$/before interpolating into the shell command. The version is currently hardcoded so injection is not possible today, but this guards against future refactors that make it configurable.Post-install binary check — after a successful spawn exit, verify
existsSync(homeBin + '/claude'). Even with pipefail, a network drop mid-transfer after bash has started could produce a truncated script that exits 0. The binary check catches that.Better retry logging — log the actual error on failed attempts (not just
"Installation failed, retrying..."), so CI logs show what actually went wrong.Changes
homeBinhoisted above the loop (was inside the success block; now shared with the binary check and PATH append)existsSyncalready imported at line 9)Fixes #1136