block / block/buzz

[Bug] git-credential-nostr absolute path with spaces breaks credential.helper (Projects + agents)

Open Beginner friendly
#3,298 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

## Summary

Buzz injects an absolute path to `git-credential-nostr` into git `credential.helper` (Projects via `GIT_CONFIG_*`, agents via spawn env). Git runs helpers through the shell (`sh -c`). If that path contains whitespace (or `'`), the value is word-split / broken and auth fails.

This is adjacent to #3025 / #3023 (backslash mangling on Git for Windows). Forward-slash normalization alone does not fix spaces.

Called out by @wpfleger96 on https://github.com/block/buzz/pull/3023:

> there's a pre-existing issue adjacent to this fix that the PR intentionally didn't touch. Git parses the `credential.helper` value as a shell command line, so a helper path containing spaces gets word-split — reproducible with `git -c credential.helper="/path with spaces/helper"`, which fails with `is not a git command`. The forward-slash normalization here (`credential_helper_config_value` in `project_git_exec.rs` and the `GIT_CONFIG_VALUE_0` write in `runtime.rs`) doesn't quote the path, so a buzz install under a spaced directory (e.g. a Windows username with a space, depending on where the helper lands) would still break. The fix is quoting the value (`"'{path}'"` or shell-escaping) at both call sites — worth its own small PR rather than piling onto this one.

## Platforms

Any OS where the helper path contains spaces (most often Windows usernames like `Buzz User`; also possible on macOS/Linux). Paths without spaces should keep today's absolute-path helper form.

## Expected

Helper path with spaces still authenticates to relay git (Projects Remote / agent git).

## Actual

Shell word-splits the helper path; clone/fetch/auth fails (e.g. `No such file or directory` / `is not a git command`).

## Proposed fix direction

At both call sites, format via shared helper:

- Always normalize `\` to `/`.
- If path has whitespace or `'`, emit `!'...'` (POSIX single-quote escaping).
- Otherwise keep plain absolute path (no happy-path launch-style change).

Local verification used Git for Windows with a spaced helper path; unit tests cover plain / spaces / apostrophe fixtures.

Contributor guide

Open the contributing guide

Research direction

Inspect the credential helper call sites in project_git_exec.rs and runtime.rs, then review the existing unit-test fixtures for plain paths, spaces, and apostrophes. Verify that both call sites use the shared formatting behavior, preserve plain absolute paths, and allow spaced or apostrophe-containing helper paths to authenticate successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, rust
Domain
security, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.