Skip to content

fix(git): clearer diagnostic when the Git config probe cannot read the config (#4390) - #4442

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-4390-git-probe-diagnostic
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-4390-git-probe-diagnostic

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Clearer diagnostic when the Git config probe behind URL rewrite safety cannot read the effective configuration. The install still refuses (fail closed). The error now shows:

  • Git's first diagnostic line, redacted: URL userinfo, tokens and quoted config values are masked, the text is printable ASCII, and its length is capped.
  • The config file and line Git reports, when present.
  • One runnable remedy, such as fix line 3 of '<file>', then check with 'git config --show-origin --list' and retry.
  • For a path-length failure ('$GIT_DIR' too big, see apm install fails on Windows when the dependency staging path exceeds Git's path limit #4397), the remedy is a shorter project path or core.longpaths.

Categories without stderr (could not start, timed out) keep their wording and add git config --show-origin --list. The owner is GitUrlRewriteProbeError in src/apm_cli/utils/git_env.py; callers render its message unchanged.

Issue and approved scope

Issue: Fixes #4390

Human scope-approval comment: #4390 (comment)

Does this PR complete the issue, or what remains? It completes the issue.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • tests/integration/test_git_config_probe_diagnostic_lifecycle.py::test_unreadable_git_config_refuses_naming_the_fault_and_a_remedy[unreadable-global-config|credential-in-invalid-key] runs on the installed CLI (APM_BINARY_PATH=.venv/bin/apm): 2 failed before the fix, 2 passed after. It asserts a non-zero exit, the file Git reports, the remedy command, no credential text, and an unchanged apm.yml with no lockfile.

  • tests/unit/utils/test_git_probe_diagnostic.py (new) and tests/unit/cache/test_git_env.py::TestGitSubprocessEnv: 89 passed.

  • tests/quality/test_lifecycle_bug_ledger.py: passed. python -m tests.quality.taxonomy --changed: clean. scripts/check_test_assertions.py: ratchet clean.

  • Lint chain: ruff check and ruff format --check, pylint R0801, lint-auth-signals.sh, the complexity ratchet (--base-ref origin/main) and lint_architecture_boundaries.py --root . are all clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

Not applicable: no req-XXX behavior changes.

…remedy (#4390)

URL rewrite safety stays fail closed when the effective Git config cannot be
read. The refusal now shows Git's first diagnostic line (credentials redacted,
printable ASCII, bounded), the config file and line Git reports, and one
runnable remedy; a path-length failure names a shorter project path or
core.longpaths. Categories without stderr keep their wording and add
'git config --show-origin --list'.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:42

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.

🟡 Changes recommended

Install errors can expose private config-value suffixes containing apostrophes, and truncated error details can direct users to fix nonexistent paths.

2 open issues
What changed in this PR

This PR improves diagnostics when APM cannot read Git configuration during URL rewrite safety checks, addressing #4390 while preserving fail-closed behavior.

Changes:

  • Adds redacted, bounded Git diagnostics and targeted recovery advice, including path-length guidance related to #4397.
  • Adds unit and installed-CLI regression coverage for diagnostics, credential masking, and unchanged project state.
  • Documents the troubleshooting command and records the fix in the changelog and lifecycle bug ledger.
File Description
tests/​unit/​utils/​test_git_probe_diagnostic.py Tests diagnostic formatting, redaction, limits, and remedies.
tests/​unit/​cache/​test_git_env.py Updates probe-failure and timeout assertions.
tests/​integration/​test_git_config_probe_diagnostic_lifecycle.py Checks CLI refusal, credential masking, and unchanged project state.
tests/​fixtures/​lifecycle_bug_ledger.json Links issue #4390 to regression coverage.
src/​apm_cli/​utils/​git_env.py Adds diagnostic sanitization and recovery guidance to probe errors.
docs/​src/​content/​docs/​getting-started/​authentication.md Documents config-read failures and the inspection command.
CHANGELOG.md Records the user-visible diagnostic improvement.

Review effort: Balanced

Comment thread src/apm_cli/utils/git_env.py Resolved
Comment thread src/apm_cli/utils/git_env.py Resolved
…the full line

A config value that contains apostrophes is masked through the suffix Git
appends, or to the end of the line. The remedy is parsed from the untruncated
redacted line, and a path longer than the display cap falls back to the
inspection command.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit abc14a5 into main Nov 21, 2026
44 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-4390-git-probe-diagnostic branch November 21, 2026 05:24
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.

Git URL rewrite safety: name the failing config and a remedy when the git config probe cannot run

2 participants