Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(issues): keep private sub-issues out of sub-issue progress counts (#10312)
pseudoyu61f84be54164
diff --git a/server/internal/handler/issue.go b/server/internal/handler/issue.goindex a96dbc84f5..941e6dd9cd 100644--- a/server/internal/handler/issue.go+++ b/server/internal/handler/issue.go@@ -2736,9 +2736,14 @@ func (h *Handler) ChildIssueProgress(w http.ResponseWriter, r *http.Request) {writeError(w, http.StatusInternalServerError, "failed to resolve status categories")return}+ hidden, ok := h.requestHiddenProjects(w, r, wsID)+ if !ok {+ return+ }rows, err := h.Queries.ChildIssueProgress(r.Context(), db.ChildIssueProgressParams{WorkspaceID: wsUUID,TerminalStatusKeys: terminalStatusKeys,+ HiddenProjectIds: hidden.Param(),})if err != nil {writeError(w, http.StatusInternalServerError, "failed to get child issue progress")diff --git a/server/internal/handler/private_project_test.go b/server/internal/handler/private_project_test.goindex 753556c470..0e86810d1f 100644--- a/server/internal/handler/private_project_test.go+++ b/server/internal/handler/private_project_test.go@@ -824,3 +824,51 @@ func TestPrivateProjectWakeupListsSkipOutsiders(t *testing.T) {}}}++// Sub-issue progress is read for every parent in one call, not through an+// issue, so its counts have to leave out sub-issues in a project the caller+// cannot see.+func TestPrivateProjectChildProgressSkipsHiddenSubIssues(t *testing.T) {+ f := newPrivateProjectFixture(t)+ dbfx.Issue(t, f.marker+" public child", testutil.Cols{"parent_issue_id": f.publicIssue})+ dbfx.Issue(t, f.marker+" secret child", testutil.Cols{"project_id": f.projectID, "parent_issue_id": f.publicIssue, "status": "done"})+ secretOnlyParent := dbfx.Issue(t, f.marker+" parent of one secret child")+ dbfx.Issue(t, f.marker+" lone secret child", testutil.Cols{"project_id": f.projectID, "parent_issue_id": secretOnlyParent})++ type counts struct{ Total, Done int64 }+ progress := func(userID string) map[string]counts {+ t.Helper()+ var body struct {+ Progress []struct {+ ParentIssueID string `json:"parent_issue_id"`+ Total int64 `json:"total"`+ Done int64 `json:"done"`+ } `json:"progress"`+ }+ req := asUser(newRequest(http.MethodGet, "/api/issues/child-progress", nil), userID)+ testutil.Call(t, testHandler.ChildIssueProgress, req).Want(http.StatusOK).JSON(&body)+ out := map[string]counts{}+ for _, p := range body.Progress {+ out[p.ParentIssueID] = counts{p.Total, p.Done}+ }+ return out+ }+ for _, tc := range []struct {+ name string+ userID string+ mixed counts+ secretOnly counts+ }{+ {"project member", f.insider, counts{2, 1}, counts{1, 0}},+ {"workspace owner outside the member list", testUserID, counts{2, 1}, counts{1, 0}},+ {"workspace member outside the project", f.outsider, counts{1, 0}, counts{}},+ } {+ got := progress(tc.userID)+ if got[f.publicIssue] != tc.mixed {+ t.Errorf("%s: parent with a public and a secret sub-issue = %+v, want %+v", tc.name, got[f.publicIssue], tc.mixed)+ }+ if got[secretOnlyParent] != tc.secretOnly {+ t.Errorf("%s: parent with only a secret sub-issue = %+v, want %+v", tc.name, got[secretOnlyParent], tc.secretOnly)+ }+ }+}diff --git a/server/pkg/db/generated/issue.sql.go b/server/pkg/db/generated/issue.sql.goindex 60a86b9424..3de0f8a867 100644--- a/server/pkg/db/generated/issue.sql.go+++ b/server/pkg/db/generated/issue.sql.go@@ -18,12 +18,15 @@ SELECT parent_issue_id,FROM issueWHERE workspace_id = $1AND parent_issue_id IS NOT NULL+ -- MUL-8472: private projects the caller cannot see.+ AND ($3::uuid[] IS NULL OR project_id IS NULL OR NOT (project_id = ANY($3::uuid[])))GROUP BY parent_issue_id`type ChildIssueProgressParams struct {- WorkspaceID pgtype.UUID `json:"workspace_id"`- TerminalStatusKeys []string `json:"terminal_status_keys"`+ WorkspaceID pgtype.UUID `json:"workspace_id"`+ TerminalStatusKeys []string `json:"terminal_status_keys"`+ HiddenProjectIds []pgtype.UUID `json:"hidden_project_ids"`}type ChildIssueProgressRow struct {@@ -33,7 +36,7 @@ type ChildIssueProgressRow struct {}func (q *Queries) ChildIssueProgress(ctx context.Context, arg ChildIssueProgressParams) ([]ChildIssueProgressRow, error) {- rows, err := q.db.Query(ctx, childIssueProgress, arg.WorkspaceID, arg.TerminalStatusKeys)+ rows, err := q.db.Query(ctx, childIssueProgress, arg.WorkspaceID, arg.TerminalStatusKeys, arg.HiddenProjectIds)if err != nil {return nil, err}diff --git a/server/pkg/db/queries/issue.sql b/server/pkg/db/queries/issue.sqlindex fa1ab1b483..96d2373e8f 100644--- a/server/pkg/db/queries/issue.sql+++ b/server/pkg/db/queries/issue.sql@@ -732,6 +732,8 @@ SELECT parent_issue_id,FROM issueWHERE workspace_id = $1AND parent_issue_id IS NOT NULL+ -- MUL-8472: private projects the caller cannot see.+ AND (sqlc.narg('hidden_project_ids')::uuid[] IS NULL OR project_id IS NULL OR NOT (project_id = ANY(sqlc.narg('hidden_project_ids')::uuid[])))GROUP BY parent_issue_id;-- SearchIssues: moved to handler (dynamic SQL for multi-word search support).