Skip to content

Bug: Switching a project's owning team to "Org-wide" orphans sharedWithTeamIds — project stays team-restricted while the UI shows "Org-wide" #2046

Closed

Description

@yannickmonney

Area / route

Projects → Overview → Sharing. /dashboard/{org}/projects/{projectId} — services/platform/app/features/projects/components/project-sharing-section.tsx (+ server services/platform/convex/projects/mutations.ts::updateProjectSharing).

Steps to reproduce

  1. As an org admin/owner, open a project owned by Team A that is also shared with Team B (teamId = A, sharedWithTeamIds = [B]).
  2. In the Sharing section, change the "Owning team" Select from Team A to "Org-wide".
  3. Confirm the narrowing-warning dialog (it appears because Team A loses access).

Expected

Either the project genuinely becomes org-wide (sharedWithTeamIds cleared so getProjectTeamIds returns []), OR the still-shared teams stay visible/removable so the admin can see and edit the real audience. The displayed Visibility must match effective access.

Actual

handleOwningTeamChange computes nextShared = sharedWithTeamIds.filter(id => id !== nextOwningTeam). Going org-wide makes nextOwningTeam = null, and null is never an element of the shared array, so no shared team is dropped. It saves { teamId: null, sharedWithTeamIds: [B] }. The server stores this verbatim (teamId cleared, sharedWithTeamIds = [B]) — validateSharing only rejects when the owning team is in the shared list, which no longer applies. So getProjectTeamIds() returns [B] and isOrgWideProject is false: the project is actually restricted to Team B (plus admins), not org-wide.

On the re-rendered Sharing section the Select shows value = teamId ?? NONE_OWNING_TEAM = "Org-wide", and the "Also shared with" multiselect is hidden because its render guard is teamId && shareableTeams.length > 0 (now undefined && … → falsy). The admin sees "Org-wide" selected with no control to view or remove Team B. Meanwhile the project overview header and the projects table both compute teamCount = (teamId?1:0) + sharedWithTeamIds.length = 1 and show "1 team". The Sharing Select silently contradicts the overview/table, effective access disagrees with the displayed Visibility, and the orphaned share can never be cleared through the UI.

Evidence (verified)

  • services/platform/app/features/projects/components/project-sharing-section.tsx:142-145 — sharedWithTeamIds.filter(id => id !== nextOwningTeam) never drops a shared team when nextOwningTeam is null (org-wide).
  • :197 — value={teamId ?? NONE_OWNING_TEAM} renders "Org-wide" once teamId is cleared.
  • :203 — multiselect guard teamId && shareableTeams.length > 0 hides the "Also shared with" control (and thus Team B) when teamId is null/undefined.
  • services/platform/convex/projects/mutations.ts:539-571 — updateProjectSharing patches teamId=undefined and sharedWithTeamIds=[B] verbatim; no normalization clearing shares when going org-wide.
  • services/platform/convex/projects/mutations.ts:245-260 — validateSharing only rejects when the owning team appears in the shared list; passes here.
  • services/platform/convex/projects/access.ts:36-49,54-55 — getProjectTeamIds returns [B] and isOrgWideProject is false with no owning team, so access is restricted to Team B.
  • services/platform/app/features/projects/components/project-overview.tsx:157-158,175-178 and projects-table.tsx:135 — both show "1 team", contradicting the "Org-wide" Select.

Notes

Two-part fix candidate: (1) When nextOwningTeam === null, clear sharedWithTeamIds to genuinely make the project org-wide (and/or have the server normalize: dropping the owning team without re-targeting shares is the ambiguous case). (2) Show the "Also shared with" audience even when org-wide so any remaining shares are visible and removable. The narrowing-confirmation dialog already fires correctly here (Team A losing access is detected), but the post-confirm result is the buggy orphaned state.


Filed by an automated manual-review pass (live browser QA + a 25-agent code-grounded audit, each finding adversarially verified). Deduped against open issues (incl. #1972–#1999, settings/forms epic #1941–#1966, audit cluster #1842–#1846) and recently-closed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automatedbugpriority: highservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions