Skip to content

fix: prevent restoreConfigFromBase from hanging on repos with submodules#1104

Open
gn00295120 wants to merge 3 commits intoanthropics:mainfrom
gn00295120:fix/restore-config-submodule-hang-and-url-encoding
Open

fix: prevent restoreConfigFromBase from hanging on repos with submodules#1104
gn00295120 wants to merge 3 commits intoanthropics:mainfrom
gn00295120:fix/restore-config-submodule-hang-and-url-encoding

Conversation

@gn00295120
Copy link
Copy Markdown

Summary

  • Fix restoreConfigFromBase hanging indefinitely on repositories with .gitmodules (submodules) by adding --no-recurse-submodules, GIT_TERMINAL_PROMPT=0, and a 60-second timeout to all git operations
  • Fix ensureProperlyEncodedUrl silently truncating query parameter values that contain = signs (e.g. body=a=b became body=a)

Fixes #1088

Details

restoreConfigFromBase hang (fixes #1088)

When a repository contains .gitmodules, git operations in restoreConfigFromBase can 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:

  • Add --no-recurse-submodules to git fetch to prevent submodule object fetching
  • Set GIT_TERMINAL_PROMPT=0 on all git subprocesses to prevent interactive credential prompts in CI
  • Set GIT_SUBMODULE_UPDATE_COMMAND=true to no-op any automatic submodule updates triggered by .gitmodules checkout
  • Add 60-second timeout to all execFileSync calls as a safety net

ensureProperlyEncodedUrl value truncation

pair.split("=") with array destructuring [key, value] only captures the first two segments. For a query parameter like body=a=b, this produces key="body", value="a" — silently dropping =b. Fixed by splitting only at the first = using indexOf.

Also fixed url.split("?") to use indexOf to correctly handle ? characters appearing in query parameter values.

Test plan

  • New test file test/restore-config.test.ts (6 tests): verifies --no-recurse-submodules, GIT_TERMINAL_PROMPT=0, timeout, and error handling
  • New tests in test/url-encoding.test.ts (4 tests): verifies = preservation in query values, multiple = signs, and ? in query values
  • All existing tests pass (13 pre-existing failures are unrelated missing-dependency issues in local env)

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
Copilot AI review requested due to automatic review settings March 23, 2026 13:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ensureProperlyEncodedUrl to 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.

gn00295120 and others added 2 commits March 23, 2026 21:19
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

restoreConfigFromBase hangs indefinitely on repositories with .gitmodules (submodules)

2 participants