fix(wiki): gitea_wiki list fails with "The target couldn't be found" on an empty wiki #9
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#9
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_wikiwithaction: "list"fails on a repository whose wiki is enabled but empty.Verbatim tool output (t14btw, 2026-10-23):
Repro
ml-lab/tardits(has_wiki: true, zero pages).gitea_wiki {action: "list", owner: "ml-lab", repo: "tardits"}→ error above.Environment: DSH
0.2.0-rc.2,dsh-gitea0.7.40-dsh.1(776e0f5, link: checkout), Forgejo17.0.0+gitea-1.22.0.Observed vs expected
Root cause (checkout available)
lib/gitea-client.js:609-613—listWikiPages()returnsthis.request('GET', …/wiki/pages)directly; no 404 handling.lib/gitea-client.js:210-216— non-ok responses become{ok:false, error: data?.message …}; Forgejo's 404messageis surfaced verbatim as the tool error.lib/handlers/repos.js:133-141—case 'gitea_wiki'passes that throughwrap()(lib/handlers/common.js:166).lib/gitea-client.js:467-474(getPullMergeStatus, #296) maps 404 to a successful, meaningful result.Proposed fix
In
listWikiPages()(or in thegitea_wikilist branch), mapstatus === 404to{ok: true, status: 404, data: []}. Optionally consult the repo'shas_wikito word "no pages yet" vs "wiki disabled", and keep the raw 404 body out of the tool error path.Acceptance
fetch404:gitea_wiki listresolvesok: truewith an empty list and no error text.gitea_wiki {action:"list", owner:"ml-lab", repo:"tardits"}returns an empty success.pvlb-infra/t14-deeps(has pages) still lists all pages.Duplicate check
Searched open + closed before filing: #4 (
getreturns onlyOK) and #5 (bareOKfor empty/unrecognised results) are related but distinct — this is thelist404 path only, first reported here.Layer
Plugin/tool bug →
dsh-gitea(correct repo).Fixed in
913013a(PR #13).listWikiPages()now maps the empty-wiki404fromGET /wiki/pagesto{ ok: true, status: 404, data: [] }; 401/403/5xx still fail. Covered bytest/wiki.test.mjs.Live check through the running plugin:
gitea_wiki {action:"list", owner:"ml-lab", repo:"tardits"}→No wiki pages.gitea_wiki {action:"list", owner:"pvlb-infra", repo:"t14-deeps"}→ all 3 pages listed.