fix(tools): commit, PR-file and compare lists dump clipped raw JSON instead of a summary #25

Closed
opened 2026-10-24 00:59:00 +00:00 by dsh · 1 comment
Owner

Symptom

Several list/compare tools print each row as a clipped raw JSON blob instead of the field summary their descriptions imply: gitea_repo_commits, gitea_pr_files, and gitea_repo_compare. A 5-commit call produces ~1.5 KB of unreadable JSON.

Repro

gitea_repo_commits {owner:"ml-lab", repo:"tardits", limit:5}
→ {"html_url":"https://git.pvlb.dev/ml-lab/tardits/commit/ca4117f...","sha":"ca4117f...","commit":{"url":"...","author":{...}} (×5, each clipped at 300 chars)

gitea_pr_files {owner:"dsh-plugins", repo:"dsh-gitea", number:18}
→ {"html_url":"...","additions":17,"deletions":3,"status":"changed","filename":"lib/handlers/formatters.js","changes":20} (×5)

gitea_repo_compare {owner:"ml-lab", repo:"tardits", range:"master...master"}
→ Unrecognised response
   {"files":[]}

Observed vs expected

  • Commits: expected ca4117f Merge pull request #1 ... (pvlb-dev, 2026-08-06) per line; observed raw JSON.
  • PR files: expected lib/handlers/formatters.js (+17/−3) per line; observed raw JSON.
  • Compare: expected 0 files changed / No changes; observed Unrecognised response + JSON.

Root cause

lib/handlers/formatters.js generic array branch only renders item.number, item.path, or item.name; commit rows have sha/commit, PR-file rows have filename/additions/deletions, and compare returns an object with files but no name/title, so all three fall through to clipSnippet. The object path also hits describeUnknownObject, which prefixes the JSON with Unrecognised response.

Proposed fix

Add explicit formatters:

  • gitea_repo_commits: short sha + first message line + author + date, with listFooter.
  • gitea_pr_files: filename + (+additions/−deletions) + status.
  • gitea_repo_compare: files/commits/ahead-behind summary, and a clear "No changes" line for an empty diff.

Tests with the three recorded payloads; acceptance: no Unrecognised response and no per-row JSON for these tools.

Duplicate check

Searched formatter (state all); #2/#5/#7/#11 closed the generic formatter family but none names commits/files/compare. #3 covered repo_contents only.

Layer

dsh-gitea plugin/tool (formatter).

## Symptom Several list/compare tools print each row as a clipped raw JSON blob instead of the field summary their descriptions imply: `gitea_repo_commits`, `gitea_pr_files`, and `gitea_repo_compare`. A 5-commit call produces ~1.5 KB of unreadable JSON. ## Repro ``` gitea_repo_commits {owner:"ml-lab", repo:"tardits", limit:5} → {"html_url":"https://git.pvlb.dev/ml-lab/tardits/commit/ca4117f...","sha":"ca4117f...","commit":{"url":"...","author":{...}} (×5, each clipped at 300 chars) gitea_pr_files {owner:"dsh-plugins", repo:"dsh-gitea", number:18} → {"html_url":"...","additions":17,"deletions":3,"status":"changed","filename":"lib/handlers/formatters.js","changes":20} (×5) gitea_repo_compare {owner:"ml-lab", repo:"tardits", range:"master...master"} → Unrecognised response {"files":[]} ``` ## Observed vs expected - Commits: expected `ca4117f Merge pull request #1 ... (pvlb-dev, 2026-08-06)` per line; observed raw JSON. - PR files: expected `lib/handlers/formatters.js (+17/−3)` per line; observed raw JSON. - Compare: expected `0 files changed` / `No changes`; observed `Unrecognised response` + JSON. ## Root cause `lib/handlers/formatters.js` generic array branch only renders `item.number`, `item.path`, or `item.name`; commit rows have `sha`/`commit`, PR-file rows have `filename`/`additions`/`deletions`, and compare returns an object with `files` but no `name`/`title`, so all three fall through to `clipSnippet`. The object path also hits `describeUnknownObject`, which prefixes the JSON with `Unrecognised response`. ## Proposed fix Add explicit formatters: - `gitea_repo_commits`: short sha + first message line + author + date, with `listFooter`. - `gitea_pr_files`: filename + `(+additions/−deletions)` + status. - `gitea_repo_compare`: files/commits/ahead-behind summary, and a clear "No changes" line for an empty diff. Tests with the three recorded payloads; acceptance: no `Unrecognised response` and no per-row JSON for these tools. ## Duplicate check Searched `formatter` (state all); #2/#5/#7/#11 closed the generic formatter family but none names commits/files/compare. #3 covered `repo_contents` only. ## Layer dsh-gitea plugin/tool (formatter).
dsh closed this issue 2026-10-24 01:22:27 +00:00
Author
Owner

Fixed in 56f41de (PR #41).

gitea_repo_commits renders sha subject (author, date); gitea_pr_files renders filename (+a/-d) [status]; gitea_repo_compare renders a commit/file summary (or Compare: No changes.) instead of per-row JSON / Unrecognised response. commits was added to RECORD_KEYS so the count survives slimRecord.

Live: 3 commits, PR #18 files, master...master → Compare: No changes.

Tests: test/qa-formatters.test.mjs.

Fixed in `56f41de` (PR #41). `gitea_repo_commits` renders `sha subject (author, date)`; `gitea_pr_files` renders `filename (+a/-d) [status]`; `gitea_repo_compare` renders a commit/file summary (or `Compare: No changes.`) instead of per-row JSON / `Unrecognised response`. `commits` was added to `RECORD_KEYS` so the count survives `slimRecord`. Live: 3 commits, PR #18 files, `master...master` → `Compare: No changes.` Tests: `test/qa-formatters.test.mjs`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
dsh-plugins/dsh-gitea#25
No description provided.