Skip to content

fix(dg): repo view says plainly why the security policy wasn't checked - #675

Merged
PastaPastaPasta merged 1 commit into
masterfrom
fix/repo-view-plain-note
Nov 24, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
fix/repo-view-plain-note

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Problem

When git-remote-dash isn't installed, dg repo view prints git's raw fetch error, which tells a new user nothing:

$ dg repo view FRxiZ1S…/nov-qa-web        # before, git-remote-dash not installed
Fetching the default branch to look for a security policy…
note: the security policy was not looked up: fetching the base branch: git fetch failed: git: 'remote-dash' is not a git command. See 'git --help'. | fatal: remote helper 'dash' aborted session
FRxiZ1S…/nov-qa-web
  id:             5Xm4XEGdQibKSNJNEE2zefAyg7goCQdeedBkJ2aUNg6Z
  ...
  remote:         dash://FRxiZ1S…/nov-qa-web

Fix

repo view now checks for the helper (on PATH and in git --exec-path) before fetching. If the policy look fails, it reports that in plain words and says what to do next:

$ dg repo view FRxiZ1S…/nov-qa-web        # after, git-remote-dash not installed
FRxiZ1S…/nov-qa-web
  id:             5Xm4XEGdQibKSNJNEE2zefAyg7goCQdeedBkJ2aUNg6Z
  description:    New-user QA pass, Nov 2026 (web-created repo)
  visibility:     public
  default branch: main
  branches:       1
    main  3e23a55fa8f6
  tags:           0
  packs:          2 (743 bytes)
  members:        1
  Security policy: not checked (git-remote-dash isn't installed, so git can't read dash:// URLs)
  remote:         dash://FRxiZ1S…/nov-qa-web
  next step:      install git-remote-dash next to dg (docs/INSTALL.md; `dg doctor` checks it), then `dg repo clone FRxiZ1S…/nov-qa-web`

The raw cause moves to --json, as securityPolicyError, next to the plain securityPolicyNote:

$ dg repo view FRxiZ1S…/nov-qa-web --json | jq '{securityPolicy,securityPolicyNote,securityPolicyError}'
{
  "securityPolicy": null,
  "securityPolicyNote": "not checked (git-remote-dash isn't installed, so git can't read dash:// URLs)",
  "securityPolicyError": "git-remote-dash was not found on PATH or in git's exec-path"
}

Both runs used real testnet, with binaries built from master (before) and from this branch (after), and a PATH that has no git-remote-dash. The schema (docs/schemas/dg/repo-view.schema.json) is regenerated. A unit test covers the plain note and the next step for a missing helper and for a failed fetch.

🤖 Generated with Claude Code

Without git-remote-dash, `dg repo view` printed git's raw fetch error on
stderr. It now reports "Security policy: not checked (…)" with a next
step (install the helper, then clone), and keeps the raw cause in
--json as securityPolicyError beside securityPolicyNote.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2195496f-8b4d-427b-a9a4-6a753b451e8a
Commits

Reviewing files that changed from the base of the PR and between b5917e6 and d73a2f9.

Files selected for processing: 4

  • CHANGELOG.md
  • crates/dg/src/repo.rs
  • docs/schemas/dg/repo-view.schema.json
  • docs/schemas/generate.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Verdict: approve

I read the diff at d73a2f9 against master and the code around it. I did not build or run anything locally. CI is the gate for that, and when I checked, rust build + test, the Windows check and the arm/x86 builds were still pending.

What I checked

  • Helper installed but the fetch fails for another reason. This is handled correctly. helper_missing = true only comes from the !helper_installed() branch, before any fetch. Every Err from security_policy_fetched goes to lookup_failed(handle, false, …), so the note says "the default branch couldn't be fetched" and never says the helper is missing. Network errors, a non-plain default branch, scratch-repo errors and a non-executable helper file all get the generic note, with the raw cause in securityPolicyError.
  • git --exec-path failing. This is handled. The Err is ignored and only PATH is searched. git runs with cwd . and needs no repository. If git itself is missing, the fetch would have failed anyway, and the generic note applies.
  • Windows. EXE_SUFFIX gives git-remote-dash.exe, which matches what the release ships. split_paths handles Windows PATH quoting. Git for Windows prints exec-path with forward slashes (C:/Program Files/Git/mingw64/libexec/git-core), and PathBuf::join accepts that. See nit 1.
  • JSON compatibility. Both new keys are additive and nullable. The schema keeps additionalProperties: true, and generate.py and the generated schema agree. No code in the repo reads the repo view JSON key set strictly. securityPolicyNote is also filled in the existing "too large" case (error is null there), which fits its schema description.
  • --json stays on stdout. It does, and it is better than before. The old eprintln!("note: … {e:#}") went to stderr even under --json, and it has been removed. Under --json the remaining stderr line ("Fetching the default branch…") is already suppressed. The note and the next step now print only in the human closure, on stdout.

Non-blocking nits

  1. crates/dg/src/repo.rs, helper_installed: on Windows, Git for Windows can also run an extensionless shebang script named git-remote-dash (and .cmd shims, via PATHEXT). A user with such a wrapper would be told the helper "isn't installed". That user runs a non-release setup, so this is low priority. Checking the bare name as well on Windows would close the gap.
  2. crates/dg/src/repo.rs, security_policy: the in-clone path (Some(found) from security_policy_in(&cwd, …)) also maps an Err to "the default branch couldn't be fetched", with the advice "dg repo clone …, then run dg repo view in the clone". The user is already in that clone, and nothing was fetched. This is rare (git ls-tree failing on an object has_object just found), but the wording is wrong there.
  3. The unit test covers lookup_failed but not helper_installed. A small test that sets PATH to a temp dir with and without a git-remote-dash{EXE_SUFFIX} file would pin it down, though changing env in tests needs care with parallel runs.

🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta merged commit ce8d6af into master Nov 24, 2026
20 checks passed
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.

1 participant