29: Bug: forgejo_issue_create/view/edit/close/etc. crash when assignees is null in the API response #32
No reviewers
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills!32
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-29/bug-forgejo-issue-create-view-edit-close-etc-crash"
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?
29: Bug: forgejo_issue_create/view/edit/close/etc. crash when assignees is null in the API response
Implements 29.
Generated in 7m 02s.
Review findings
The working tree is clean at commit
19f83fd(the Stage 1 commit). Let me examine the files involved in the Medium finding.Now let me look at the exactformatPullRequestsection inindex.tsand the test file structure.I have full context. Now let me apply the Medium finding fixes. First theformatPullRequestnormalization inindex.tsand the interface change inpulls.ts:Now let me look at the end of the test file to add the null-headregression test:Now I'll add the null-headregression test:Let me check for any other dereferences ofbase.ref/head.refin the codebase, and verify the edits:The grep failed due to shell quoting. Let me retry with proper quoting:The remaining references are in tests with present-data fixtures (fine — a non-null object is assignable to| null). Let me checkpulls.test.tsaround those lines to confirm nothing breaks:Now let me discover the build/test/lint commands for the forgejo extension:Found the gates:npm run build(tsc),npm run check(tsc --noEmit),npm test(jest) inextensions/forgejo. Let me run them:The updated| nullinterface surfaced two typecheck errors inpulls.test.tswhere the present-data assertions dereferencebase.ref/head.ref. Minimal fix: use optional chaining (the fixture provides real objects, so the assertions still verify present data):All 8 suites pass (117 tests — 116 + the 1 new null-head test). Let me re-run build/check and review the final working-tree diff:Let me review the final diff to confirm correctness:All gates pass and the diff is minimal and consistent. The Medium finding is fully resolved (normalization informatPullRequest,| nullin the interface, new null-headregression test, plus two typecheck errors inpulls.test.tssurfaced by the interface widening that I fixed with optional chaining). The Low finding (commit message amend) requires a git history rewrite, which this stage forbids, so it remains unresolved.Review Findings — 29
Summary
The reported crash (null
assignees/labelsfrom the Forgejo API) is fixed:formatIssue/formatPullRequestnow normalize both fields with?? [], theForgejoIssue/ForgejoPullRequestinterfaces are updated to reflect the nullable response shape, and 9 regression tests cover the null cases plus the present-data path. Gates run:npm run build(tsc) — PASS;npm run check(tsc --noEmit) — PASS;npm test(jest) — PASS (8 suites, 116 tests, incl. 9 new regression tests). No lint gate exists in this repo (no lint script in anypackage.json, no eslint/prettier/biome config), so lint was not run. No Critical or High findings; one adjacent null-crash risk and one workflow-convention nit below.Remediation pass (single pass): the Medium finding is resolved —
formatPullRequestnow normalizesbase/headwith?? nulland rendersbase?.ref ?? ""/head?.ref ?? ""in both the display text anddetails;ForgejoPullRequest.base/headare typed| null; a null-headregression test was added; the interface widening surfaced twoTS18047errors intests/pulls.test.ts(present-data assertions onbase.ref/head.ref) which were fixed with optional chaining. Re-ran gates after the fix:npm run build— PASS;npm run check— PASS;npm test— PASS (8 suites, 117 tests, incl. the new null-headtest). The Low finding is left unresolved: the suggested fix is to amend commit19f83fd's message, but this stage forbids commit operations (includinggit commit --amend) and the pipeline captures only the working-tree diff, so a message rewrite is not actionable here.Critical
High
Medium
extensions/forgejo/src/index.ts:174—formatPullRequeststill unconditionally dereferencespr.base.refandpr.head.ref(also indetailsat lines 199–200). Gitea/Forgejo can returnbase: null/head: nullfor PRs whose head/base branch or fork was deleted — the same nullability class as this bug — soforgejo_pr_view/forgejo_pr_edit/forgejo_pr_close/forgejo_pr_assignwould crash with "Cannot read properties of null (reading 'ref')". Suggested fix: normalizeconst base = pr.base ?? null; const head = pr.head ?? null;, renderbase?.ref ?? ""/head?.ref ?? ""at lines 174/199/200, and changeForgejoPullRequest.base/head(extensions/forgejo/src/pulls.ts:14-15) to| null; add a null-headregression test mirroring the newassignees: nulltests.Low
AGENTS.md:30(commit19f83fd) — commit message violates the documentedissue-<N>: <summary>format; the subject is29: Bug: ...(missing theissue-prefix). Suggested fix: amend the commit message toissue-29: Bug: forgejo_issue_create/view/edit/close/etc. crash when assignees is null in the API response(branch namefeature/issue-29/...is already correct).