You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] Public API: module completed_issues and other state counts are always 0 or 1 #10253
GET /api/v1/workspaces/{slug}/projects/{project_id}/modules/ and the module detail endpoint return completed_issues, cancelled_issues, started_issues, unstarted_issues and backlog_issues as 0 or 1, whatever the real number is. total_issues is correct. The web app shows the correct numbers.
Cause
In apps/api/plane/api/views/module.py (list, retrieve and archived views), each state count is:
The query counts the distinct values of state__group, and the filter fixes that same field to one value. So COUNT(DISTINCT ...) can only return 0 or 1. The count must be on the issue, for example Count("issue_module__issue", filter=..., distinct=True).
The web view apps/api/plane/app/views/module/base.py uses a different query and is correct. #8595 fixed the web path but did not change the public API, so the two now differ.
Reproduce
Create a module with 3 issues.
Move all 3 issues to a Completed state.
Call GET /api/v1/workspaces/{slug}/projects/{project_id}/modules/{module_id}/.
We saw this on a self-hosted instance: a module with 10 completed issues of 18 returned completed_issues: 1, and modules with 2 and 3 cancelled issues returned cancelled_issues: 1.
Fix status
The code is unchanged on preview and master (checked 2026-11-10). Open PR #9275 (performance) replaces these annotations with _module_issue_count_subquery(), which counts ModuleIssue rows and so fixes this bug as a side effect. Merging #9275, or a one-line change for each annotation, closes this issue.
Activity