Skip to content

[match] fail fast for SSH authentication prompts in non-interactive shell#30078

Merged
iBotPeaches merged 2 commits into
fastlane:masterfrom
PratikPatil131:master
Jun 28, 2026
Merged

[match] fail fast for SSH authentication prompts in non-interactive shell#30078
iBotPeaches merged 2 commits into
fastlane:masterfrom
PratikPatil131:master

Conversation

@PratikPatil131

@PratikPatil131 PratikPatil131 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR makes match fail fast instead of hanging when SSH authentication requires interactive input (for example, passphrase or password prompts in non-interactive CI environments).

match already sets GIT_TERMINAL_PROMPT=0, which prevents interactive Git/HTTPS credential prompts. However, SSH authentication prompts can still block indefinitely. This change enables non-interactive SSH behavior by default for match Git operations using BatchMode=yes.

What changed

  • Reuse the shared Git environment helper for match clone and push operations.

  • Continue setting:

    • GIT_TERMINAL_PROMPT=0
  • Add default SSH fail-fast behavior:

    • Configure GIT_SSH_COMMAND with -o BatchMode=yes.
  • Preserve any existing user-provided GIT_SSH_COMMAND and append -o BatchMode=yes only if it is not already present.

  • Add tests covering:

    • Default behavior when GIT_SSH_COMMAND is unset.
    • Appending BatchMode=yes to an existing GIT_SSH_COMMAND.
    • Avoiding duplicate BatchMode=yes options.

Why

Without this change, match can appear to hang indefinitely while waiting for SSH authentication input that is unavailable in CI or other non-interactive environments. Enabling BatchMode=yes causes SSH to fail immediately with a clear authentication error instead of waiting for user input.

Backward compatibility

  • BatchMode is a long-standing and widely supported OpenSSH option.
  • Existing GIT_SSH_COMMAND values are preserved.
  • This change only affects interactive SSH authentication during match Git operations by converting hangs into fast failures.

Related issue

Fixes: #26591

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates match’s Git operations to avoid hanging in non-interactive environments by centralizing Git-related environment variables and introducing SSH fail-fast behavior via BatchMode=yes.

Changes:

  • Replaces inline Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') usage with a shared git_env_values helper for clone/push.
  • Adds logic intended to enforce non-interactive SSH behavior by augmenting GIT_SSH_COMMAND with -o BatchMode=yes.
  • Adds specs around git_env_values behavior with/without an existing GIT_SSH_COMMAND.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
match/lib/match/storage/git_storage.rb Introduces git_env_values / non_interactive_git_ssh_command and uses them for clone + push env setup.
match/spec/storage/git_storage_spec.rb Adds unit tests covering the new env helper behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread match/lib/match/storage/git_storage.rb
Comment thread match/spec/storage/git_storage_spec.rb Outdated
@iBotPeaches iBotPeaches changed the title match: fail fast for SSH authentication prompts in non-interactive en… [match] fail fast for SSH authentication prompts in non-interactive shell Jun 18, 2026
@iBotPeaches

Copy link
Copy Markdown
Member

Is there an easy way for me to test this locally short of setting up a real match github repo and not having the auth in my keychain?

@PratikPatil131

PratikPatil131 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@iBotPeaches You don't need to set up a real match repo for this. Here are two quick ways to test:

Option 1: Test the code directly

ruby-e"

require_relative 'match/lib/match/storage/git_storage'

storage = Match::Storage::GitStorage.new

env=storage.send(:git_env_values)

puts 'Environment variables:"

env.each { |k, v| puts " #{k}=#{v}"}
"

#Output: GIT_TERMINAL PROMPT=0, GIT_SSH_COMMAND=ssh-o BatchMode=yes

Option 2: Test with a bare repo

git init --bare /tmp/test-repo.git

git clone file:///tmp/test-repo.git /tmp/clone-test \

-C GIT TERMINAL PROMPT=01 \

-C GIT_SSH_COMMAND="ssh-o BatchMode=yes"

#Should clone successfully

I've tested both locally and everything checks out. The code generates the right env vars and git operations work as expected.

🙏 let me know if you need anything else.

@iBotPeaches iBotPeaches left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I confirmed testing with my ssh-agent empty (thus stalled forever) and this which didn't.

@iBotPeaches iBotPeaches merged commit dd954d6 into fastlane:master Jun 28, 2026
9 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @PratikPatil131 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a month, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀"

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Congratulations! 🎉 This was released as part of fastlane 2.237.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stuck cloning repos when ssh passphrase is not in the ssh-agent

3 participants