fix(health): gitea_project_health reports "Open PRs: unknown (API error)" when the only error says "unprotected" #19
Labels
No labels
area/dsh
area/forgejo
experiment
priority/later
priority/next
priority/now
type/bug
type/task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
dsh-plugins/dsh-gitea#19
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
gitea_project_healthprintsOpen PRs: unknown (API error)even when the pulls API is healthy, because the security warning contains the substringpr.Repro
gitea_project_health {owner: "dsh-plugins", repo: "dsh-gitea"}Verbatim output:
gitea_pr_list {state:"open"}on the same repo returnedNo pull requests., so the pulls fetch was fine.Observed vs expected
unknown (API error)whenever the only error is about an unprotected branch.Open PRs: 0; theunknownfallback only for a real pulls/PR API failure.Root cause
lib/handlers/formatters.jsdecides:"default branch ... is unprotected"containspr, sohasPullErris true. The same substring approach is used for issues (/issue/).Proposed fix
Match structured error prefixes/codes (
pulls:/issues:) or have the health handler report per-section error flags instead of parsing prose. Add a regression test with{openPRs: 0, errors: ["security: ... unprotected"]}assertingOpen PRs: 0.Acceptance: health output keeps the numeric PR count when only the security check failed;
unknown (API error)appears only for a genuine pulls failure.Duplicate check
gitea_issue_search {q:"formatter",state:"all"}and{q:"security"}→ only the known #2–#18 tool issues; none mentionsproject_health.Layer
dsh-gitea plugin/tool (formatter).
Fixed in
281eade(PR #40).gitea_project_healthnow matches source-prefixed errors (issues:,pulls:) instead of/pull|pr/i, sosecurity: … is unprotectedno longer hides the PR count. Live:Open Issues: 16 … Open PRs: 0with the security warning still shown.Tests:
test/qa-defaults.test.mjs.