fix: prevent restoreConfigFromBase from hanging on repos with submodules#1104
Open
gn00295120 wants to merge 3 commits intoanthropics:mainfrom
Open
fix: prevent restoreConfigFromBase from hanging on repos with submodules#1104gn00295120 wants to merge 3 commits intoanthropics:mainfrom
gn00295120 wants to merge 3 commits intoanthropics:mainfrom
Conversation
restoreConfigFromBase hangs indefinitely on repositories with .gitmodules because git operations can trigger recursive submodule fetching or credential prompts with no timeout. - Add --no-recurse-submodules to git fetch - Set GIT_TERMINAL_PROMPT=0 on all git subprocesses - Set GIT_SUBMODULE_UPDATE_COMMAND=true to no-op submodule updates - Add 60-second timeout to all execFileSync calls Also fix ensureProperlyEncodedUrl silently truncating query parameter values containing '=' (e.g. body=a=b became body=a) by splitting only at the first '=' per key-value pair. Fixes anthropics#1088
There was a problem hiding this comment.
Pull request overview
Fixes two hang/encoding issues in the GitHub action’s helper operations: (1) restoreConfigFromBase hanging on repos with submodules, and (2) ensureProperlyEncodedUrl truncating query values containing = / mishandling ? in query values.
Changes:
- Add safer git invocation defaults for
restoreConfigFromBase(--no-recurse-submodules,GIT_TERMINAL_PROMPT=0, per-command timeout). - Fix query parsing in
ensureProperlyEncodedUrlto split on the first=and first?(fast-path). - Add regression tests for both behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/github/operations/restore-config.ts |
Adds timeout + env overrides to prevent git hangs when submodules/credentials are involved. |
src/github/operations/comment-logic.ts |
Fixes query parsing so = and ? in values don’t get truncated (in the main path). |
test/restore-config.test.ts |
New unit tests for git flags/env/timeout + error tolerance behavior. |
test/url-encoding.test.ts |
New regression tests for = preservation and ? handling in query values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… values Mirror the indexOf approach from the main path in the fallback catch block, so query parameter values containing ? are not truncated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use dynamic import in test to guarantee mock bindings are active - Type SAFE_GIT_ENV as NodeJS.ProcessEnv instead of casting Record<string, string> Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
restoreConfigFromBasehanging indefinitely on repositories with.gitmodules(submodules) by adding--no-recurse-submodules,GIT_TERMINAL_PROMPT=0, and a 60-second timeout to all git operationsensureProperlyEncodedUrlsilently truncating query parameter values that contain=signs (e.g.body=a=bbecamebody=a)Fixes #1088
Details
restoreConfigFromBasehang (fixes #1088)When a repository contains
.gitmodules, git operations inrestoreConfigFromBasecan trigger recursive submodule fetching or credential prompts, causing the action to hang for hours with no output.Changes to
src/github/operations/restore-config.ts:--no-recurse-submodulestogit fetchto prevent submodule object fetchingGIT_TERMINAL_PROMPT=0on all git subprocesses to prevent interactive credential prompts in CIGIT_SUBMODULE_UPDATE_COMMAND=trueto no-op any automatic submodule updates triggered by.gitmodulescheckouttimeoutto allexecFileSynccalls as a safety netensureProperlyEncodedUrlvalue truncationpair.split("=")with array destructuring[key, value]only captures the first two segments. For a query parameter likebody=a=b, this produceskey="body",value="a"— silently dropping=b. Fixed by splitting only at the first=usingindexOf.Also fixed
url.split("?")to useindexOfto correctly handle?characters appearing in query parameter values.Test plan
test/restore-config.test.ts(6 tests): verifies--no-recurse-submodules,GIT_TERMINAL_PROMPT=0, timeout, and error handlingtest/url-encoding.test.ts(4 tests): verifies=preservation in query values, multiple=signs, and?in query values