Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(wakeup): keep private sub-issues out of the child-done system rule (#10295)

pseudoyu9713a6343ded
diff --git a/server/internal/handler/issue_system_wakeup.go b/server/internal/handler/issue_system_wakeup.go
index 5ac4460e36..8049b51ce5 100644
--- a/server/internal/handler/issue_system_wakeup.go
+++ b/server/internal/handler/issue_system_wakeup.go
@@ -56,9 +56,10 @@ type systemWakeupResponse struct {
WorkspaceDefault bool `json:"workspace_default"`
}
-// childDoneSystemWakeup describes what the parent is waiting for. It returns
-// nil when there is nothing left to wait for: no sub-issues, every sub-issue
-// closed, or the parent itself closed.
+// childDoneSystemWakeup describes what the parent is waiting for, counting
+// only the sub-issues the request may see (MUL-8472). It returns nil when
+// there is nothing left to wait for: no sub-issues, every sub-issue closed,
+// or the parent itself closed.
func (h *Handler) childDoneSystemWakeup(r *http.Request, parent db.Issue) (*systemWakeupResponse, error) {
ctx := r.Context()
categories := map[string]string{}
@@ -80,6 +81,11 @@ func (h *Handler) childDoneSystemWakeup(r *http.Request, parent db.Issue) (*syst
if err != nil || len(children) == 0 {
return nil, err
}
+ hidden, err := h.hiddenProjects(r, uuidToString(parent.WorkspaceID))
+ if err != nil {
+ return nil, err
+ }
+ children = filterVisibleIssues(hidden, children)
open := make([]db.Issue, 0, len(children))
var stage pgtype.Int4
for _, c := range children {
diff --git a/server/internal/handler/private_project_test.go b/server/internal/handler/private_project_test.go
index ea122c12fa..50a719b9e2 100644
--- a/server/internal/handler/private_project_test.go
+++ b/server/internal/handler/private_project_test.go
@@ -987,6 +987,71 @@ func TestPrivateProjectChildProgressSkipsHiddenSubIssues(t *testing.T) {
}
}
+// A public parent can hold sub-issues from a private project. Its child-done
+// system rule counts and names only the sub-issues the viewer can see.
+func TestPrivateProjectSystemWakeupSkipsHiddenChildren(t *testing.T) {
+ f := newPrivateProjectFixture(t)
+ dbfx.Exec(t, "UPDATE issue SET parent_issue_id=$1 WHERE id=$2", f.publicIssue, f.secretIssue)
+ publicChild := dbfx.Issue(t, f.marker+" public child", testutil.Cols{"parent_issue_id": f.publicIssue})
+ var secretNumber int
+ dbfx.QueryRow(t, "SELECT number FROM issue WHERE id=$1", f.secretIssue).Scan(&secretNumber)
+ secretSuffix := fmt.Sprintf("-%d", secretNumber)
+
+ childDone := func(userID string) []systemWakeupResponse {
+ t.Helper()
+ var rules []systemWakeupResponse
+ req := withURLParam(asUser(newRequest(http.MethodGet, "/api/issues/"+f.publicIssue+"/system-wakeups", nil), userID), "id", f.publicIssue)
+ testutil.Call(t, testHandler.ListIssueSystemWakeups, req).Want(http.StatusOK).JSON(&rules)
+ return rules
+ }
+ namesSecretChild := func(rule systemWakeupResponse) bool {
+ for _, identifier := range rule.Waiting {
+ if strings.HasSuffix(identifier, secretSuffix) {
+ return true
+ }
+ }
+ return false
+ }
+ viewers := []struct {
+ name string
+ userID string
+ visible bool
+ }{
+ {"project member", f.insider, true},
+ {"workspace owner in the member list", testUserID, true},
+ {"workspace member outside the project", f.outsider, false},
+ {"workspace admin outside the project", f.outsideAdmin, false},
+ }
+ for _, tc := range viewers {
+ rules := childDone(tc.userID)
+ if len(rules) != 1 {
+ t.Fatalf("%s: got %d system rules, want the child-done rule", tc.name, len(rules))
+ }
+ want := 1
+ if tc.visible {
+ want = 2
+ }
+ if rule := rules[0]; rule.Total != want || rule.Remaining != want || len(rule.Waiting) != want || namesSecretChild(rule) != tc.visible {
+ t.Errorf("%s: child-done rule waits for %d of %d (%v), want %d sub-issues and the private one named = %v", tc.name, rule.Remaining, rule.Total, rule.Waiting, want, tc.visible)
+ }
+ }
+
+ // Only the private sub-issue is still open.
+ dbfx.Exec(t, "UPDATE issue SET status='done' WHERE id=$1", publicChild)
+ for _, tc := range viewers {
+ rules := childDone(tc.userID)
+ if !tc.visible {
+ if len(rules) != 0 {
+ t.Errorf("%s: child-done rule still reported for a private sub-issue: %+v", tc.name, rules)
+ }
+ continue
+ }
+ if len(rules) != 1 || rules[0].Total != 2 || rules[0].Remaining != 1 || !namesSecretChild(rules[0]) {
+ t.Errorf("%s: child-done rule = %+v, want 1 of 2 left and the private one named", tc.name, rules)
+ }
+ }
+}
+
func TestPrivateProjectPullRequestSummariesSkipHiddenIssues(t *testing.T) {
f := newPrivateProjectFixture(t)
now := time.Now()