Skip to content

fix(git-panel): log route answers 503 for discovery outages - #12933

Merged
bolichen97 merged 1 commit into
mainfrom
fix/git-log-route-unavailable-10892
Sep 23, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/git-log-route-unavailable-10892

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What

GET /api/project/git/log now classifies repository discovery the way the status route does. Only Git's own fatal: not a git repository verdict (or a project directory that vanished) answers 200 {"repo": false, "commits": []}. Every other failed rev-parse --git-dir probe -- sandbox refusal, spawn failure, dubious ownership, permission failure, timeout/kill, corrupt repository metadata -- answers 503 {"error": "Couldn't read the commit history.", "code": "git_log_unavailable"}.

The Git panel renders that code as the untitled, localized log notice (mirroring git_status_unavailable) and no longer shows the "No changes or commits to display." empty state while the log route has failed.

Why

The log route collapsed every nonzero probe into the not-a-repository answer, so an outage rendered as an empty history. The status route was fixed in #10794 (and #11982 added the filter-driver refusal to both routes) but left this branch; the panel therefore drew an empty commit list over a log nobody read, indistinguishable from a brand-new repository. Issue #10892's second item (labelling stale status data after a failed refresh) is already on main -- the header hides branch/ahead-behind under statusError and the status notice names the stale-history clause -- so this PR owns the remaining log-route half.

How

Backend (src/kiro_crew/dashboard/handlers/files.py):

  • New _is_not_a_repo_verdict(probe_stderr) -- the one classification contract. The status route's inline any(... startswith("fatal: not a git repository")) moved into it unchanged; the log route now calls the same predicate.
  • The log route's _run uses _probe_git_dir(base, _env) (bounded stderr, capture="stderr") instead of a bare _run_git_bounded stdout probe, with LC_ALL=C / LANGUAGE=C added to its env so the English verdict matches, exactly as the status route pins it.
  • Not-a-repo -> {"repo": False, "commits": []}; any other nonzero -> {"_log_unavailable": True}, answered as 503 git_log_unavailable beside the existing git_log_filter_refused branch, after the same _project_directory_absent re-check the status route performs (a directory deleted between the isdir gate and the spawn is absence, not an outage).
  • Deliberately unchanged: log_rc != 0 -> {"repo": True, "commits": []} (unborn HEAD exits 128 there; settled in fix(git-panel): stop drawing a clean pill over a status we never read #11982) and the rev-parse --short HEAD handling.

Every git route in files.py, and how each classifies a discovery failure after this change:

Route Probe Verdict
GET /api/project/git/status _probe_git_dir + _is_not_a_repo_verdict not-a-repo -> repo: false; else 503 git_status_unavailable (unchanged)
GET /api/project/git/log _probe_git_dir + _is_not_a_repo_verdict not-a-repo -> repo: false; else 503 git_log_unavailable (this PR)
GET /api/project/git no subprocess; walks for .git and reads HEAD no .git found -> repo: false; unreadable HEAD -> repo: true with no branch (decorative label; degrades by design, out of scope)
GET /api/project/tree bare rev-parse --git-dir any nonzero -> repo: false and a full filesystem walk (the listing still renders from the filesystem, so no user-visible collapse; out of scope)
GET /api/file/diff subprocess.run(... check=True) any preflight failure -> status: "not_git" ("there is no baseline" is a statement about the file; documented in-line; out of scope)

Frontend (website/src/components/GitPanel.tsx):

  • logUnavailable = gitErrorCode(logError) === 'git_log_unavailable' -> untitled ErrorNotice with the existing components.gitPanel.log_failed copy (no new i18n key), mirroring the statusUnavailable branch. Uncoded log failures keep their titled rendering.
  • The clean-repository empty state is gated on !logError: "no commits to display" beside a notice saying history could not be read presents an outage as an empty history.

Docs: docs/system-specs/modules/learn-cron-dashboard.md git-panel route paragraph now documents git_log_unavailable, the shared predicate, and the empty-state suppression.

Tests

Backend, test/test_project_git_status_log.py, new TestGitLogDiscoveryBoundary (12 cases): explicit not-a-repository verdict incl. non-UTF-8 stderr (asserts LC_ALL=C, LANGUAGE=C, stderr captured / stdout discarded); real non-repository directory; path text containing "not a git repository" does not claim absence (503); sandbox refusal (sandboxed_spawn_argv raises); spawn OSError; stderr overflow kill (-9, proc killed and waited); probe timeout (-9); corrupt .git/config with real Git (probe exits 128 with bad config line, asserted not to be the verdict -> 503); unborn repository stays 200 {"repo": true, "commits": []}; directory vanished after probe failure -> repo: false; and the shared predicate's truth table.

Frontend, website/src/test/GitPanel.test.tsx, new GitPanel log route outage block: the coded 503 renders one untitled notice with the localized copy (server sentence absent), keeps the clean pill, suppresses the empty state and the Commits header, keeps Refresh live, and hands the agent a report carrying git_log_unavailable; an uncoded log failure keeps its titled rendering.

Run locally by path: the two changed test files (71 backend, 29 frontend, all green). Static gates: black baseline gate, isort, flake8, mypy, comment-history gate, tsc -b --force, eslint on changed files -- all exit 0. Full suites run in CI.

Screenshots

Real built SPA served by website/scripts/capture-git-log-unavailable.mjs (committed) with the status route fixtured clean and the log route fixtured 503 git_log_unavailable. The harness asserts no role=dialog is open, 0 notice titles, 0 empty-state matches, the clean pill present and Refresh enabled before each shot.

Dark:

Git panel, log unavailable, dark

Light:

Git panel, log unavailable, light

Pattern harvest

Rule candidate: when two sibling routes probe the same external boundary (here Git repository discovery), the verdict predicate lives in ONE named helper both call; an inline copy in one route is where the second route's classification silently drifts. Also: a UI empty state must be gated on the data source that would fill it having actually answered -- isClean && no commits is only "nothing to show" when the log query succeeded.

Not generalizable: the exact fatal: not a git repository string match and the LC_ALL=C pin are Git-specific; the log_rc != 0 -> repo: true carve-out exists only because an unborn repository exits 128 on git log.

Other

  • GET /api/project/tree and GET /api/file/diff keep their own discovery handling (table above); both degrade to a rendered listing / "no baseline" rather than to a false empty history, so they are outside this issue's collapse.
  • No new i18n keys; no schema changes; git_log_unavailable is additive to the 503 body contract.

Closes #10892

@CrysisDeu
CrysisDeu requested review from a team and buluoray September 22, 2026 22:40
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of b6583cf771be8b9ef541380fae52c7693690569d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] b6583cf

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of b6583cf771be8b9ef541380fae52c7693690569d and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b6583cf

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b6583cf771be8b9ef541380fae52c7693690569d: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of b6583cf771be8b9ef541380fae52c7693690569d — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify the pre-existing capture-git-panel-refusal-scope.mjs LOG_OUTAGE fixture (line 125-129): its comment pins the titled-with-server-message rendering this PR removes for git_log_unavailable.

That harness's divergent-status frame still passes its own assertions (they key on the refusal title only), but its fixture comment now describes rendering the panel no longer does for that code — one comment to refresh, nothing structural.

What this change ships

Inventory (8 items) — 8 justified

Intent: stop a failed commit-history read from rendering as an empty history (issue #10892, log-route half) — a FIX.

  1. Log route answers 503 git_log_unavailable on discovery outage instead of an empty history — justified
  2. Status route's inline not-a-repo check moved into shared _is_not_a_repo_verdict — justified
  3. Log probe now pins LC_ALL=C/LANGUAGE=C with bounded stderr via _probe_git_dir — justified
  4. Directory vanished mid-request still answers "not a repository", not an outage — justified
  5. Panel shows the coded log outage as an untitled localized notice, never the server's English — justified
  6. "No changes or commits to display" no longer shows while the log read failed — justified
  7. New committed screenshot harness for the log-outage state — justified
  8. Spec paragraph updated in the same commit — justified

Sibling routes counted and verified against the description's table: /api/project/tree (files.py:7897) degrades to a filesystem walk, /api/file/diff (files.py:5695) documents its not_git preflight in-line — neither collapses an outage into a false empty answer. git_log_unavailable has one real consumer (GitPanel.tsx:115); the predicate has two (both routes). The test hunk is pure addition — no pins deleted.

[FIRST-PRINCIPLES-REVIEWED] b6583cf

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of b6583cf771be8b9ef541380fae52c7693690569d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

Outage notice isn't visually scoped to history: blind reader couldn't reconcile the green "clean" pill or the blank body below with the red error.

Watch

  • The new git_log_unavailable notice renders in the top error area while the clean pill stays green and the Commits header/empty state are suppressed, so the reader saw contradiction plus unexplained blankness: "I can't tell whether things are fine or broken from this panel alone" and, of the body, "No idea." Divergent-failure state only (moderate frequency), mild confusion, every render of the outage. Smallest fix: keep the Commits section header and render the log notice beneath it, so the failure reads as scoped to history rather than the whole panel.

Suggestions

  • en.manual.json components.gitPanel.log_failed says "commit log" while its own hand-off link says "about the history" (and every other locale already says "history") — the reader flagged the log/history double duty; change it to "Couldn't read the commit history."

[UX-REVIEWED] b6583cf

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed b6583cf771be8b9ef541380fae52c7693690569d — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b6583cf

Verdict parsed from the review's SHA-scoped output markers for commit b6583cf771be8b9ef541380fae52c7693690569d.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b6583cf771be8b9ef541380fae52c7693690569d: <one-sentence reason>

@CrysisDeu
CrysisDeu force-pushed the fix/git-log-route-unavailable-10892 branch from 3caf94e to e02107e Compare September 22, 2026 23:47
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 22, 2026
…mpty history

`GET /api/project/git/log` turned every nonzero `rev-parse --git-dir` into
`200 {"repo": false, "commits": []}`, so a sandbox refusal, spawn failure,
timeout or corrupt repository metadata rendered as "no history" in the Git
panel. The status route already classifies discovery through `_probe_git_dir`
and only Git's own `fatal: not a git repository` verdict is absence.

Backend: the log route now uses the same `_probe_git_dir` probe (LC_ALL=C so
the English verdict matches) and a shared `_is_not_a_repo_verdict` predicate,
lifted out of the status route so both routes carry one classification
contract. Not-a-repo or a vanished directory -> `repo: false`; any other probe
failure -> `503 {"code": "git_log_unavailable"}` beside the existing
`git_log_filter_refused` branch. A nonzero `git log` after a successful probe
stays `repo: true, commits: []` (unborn HEAD).

Frontend: GitPanel renders `git_log_unavailable` as the untitled localized
log notice (mirrors `git_status_unavailable`) and no longer shows the
"No changes or commits to display." empty state while the log route has
failed. Capture harness `capture-git-log-unavailable.mjs` shoots the state.

Closes #10892
@CrysisDeu
CrysisDeu force-pushed the fix/git-log-route-unavailable-10892 branch from e02107e to b6583cf Compare September 23, 2026 00:38
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 23, 2026

@bolichen97 bolichen97 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.

Approved after verified readiness: passed, PR Readiness success on this head, mergeable, no open change requests. [operator: bolichen97 batch review 2026-09-23]

@bolichen97
bolichen97 merged commit 9071c78 into main Sep 23, 2026
97 of 99 checks passed
@bolichen97
bolichen97 deleted the fix/git-log-route-unavailable-10892 branch September 23, 2026 04:37
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 23, 2026
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
…mpty history (kirodotdev#12933)

`GET /api/project/git/log` turned every nonzero `rev-parse --git-dir` into
`200 {"repo": false, "commits": []}`, so a sandbox refusal, spawn failure,
timeout or corrupt repository metadata rendered as "no history" in the Git
panel. The status route already classifies discovery through `_probe_git_dir`
and only Git's own `fatal: not a git repository` verdict is absence.

Backend: the log route now uses the same `_probe_git_dir` probe (LC_ALL=C so
the English verdict matches) and a shared `_is_not_a_repo_verdict` predicate,
lifted out of the status route so both routes carry one classification
contract. Not-a-repo or a vanished directory -> `repo: false`; any other probe
failure -> `503 {"code": "git_log_unavailable"}` beside the existing
`git_log_filter_refused` branch. A nonzero `git log` after a successful probe
stays `repo: true, commits: []` (unborn HEAD).

Frontend: GitPanel renders `git_log_unavailable` as the untitled localized
log notice (mirrors `git_status_unavailable`) and no longer shows the
"No changes or commits to display." empty state while the log route has
failed. Capture harness `capture-git-log-unavailable.mjs` shoots the state.

Closes kirodotdev#10892
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 panel log route collapses discovery failures into an empty commit list

2 participants