Repository navigation
fix(communities): adopt the applicant's own organization holding the community slug - #468
Merged
Merged
Conversation
…community slug Resume dead-ended on "The community slug is already used by another organization" when an unbound organization owned by the applicant (or, for applications saved without an applicant user, any unbound organization) already held the community slug. The slug path now binds such an organization to the proposal instead of conflicting: it approves a pending org, stamps the community metadata plus a communityLinkedOrg marker, keeps existing owners, adds the reviewer as admin, provisions default teams, and never re-invites the applicant. Ownership is still enforced when the payload has an applicant user, and organizations bound to another proposal still conflict. releaseCommunityOrganization keeps marked organizations (keptReason "existing") so a later failed setup cannot delete a pre-existing organization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resume no longer dead-ends on "The community slug is already used by another organization" when the applicant's own organization — the one holding the community slug — is unbound (no
communityProposalIdmetadata). This mostly hits applications saved beforeorgId/applicantUserIdwere added to the payload, likeprop_1789100065387_hfx9n44(chicago): the slug path only saw the conflict.Adoption (
bindCommunityOrganization, extracted from the legacy path):applicantMetadata+communityLinkedOrg: "true"applicantInvited: false)applicantUserId, still requires the applicant to be an owner member or requester (mirrors the apply pagelinkedOrganizationrule)Release safety —
releaseCommunityOrganization:if (metadata.communityProposalId !== proposalId) return keptReason "not_found" + if (metadata.communityLinkedOrg === "true") return keptReason "existing"Marked orgs are never deleted on a later failed setup (the existing UI already treats
"existing"as "organization kept").Evidence
applyCommunityProposalrejects withCONFLICT "The community slug is already used by another organization"for any slug-matched org without matchingcommunityProposalId— including the applicant's own.api/tests/integration/community-proposals.test.ts):binds the applicant's own unbound organization at the community slug— owner/requester match → adopted, metadata stamped, teams provisioned, tenantorgIdset, resume idempotentbinds an unbound slug-matched organization when the application saved no applicant user— adopted on admin trust; release returns{ released: false, keptReason: "existing" }anddeleteOrganizationis not called; re-apply resumesstill refuses a slug-matched organization held by another application or another owner— bound-to-other → slug conflict; non-owner applicant → ownership conflictMerge Danger
Door: two-way — provisioning changes are metadata stamps and member/role adjustments; an existing provisioned application can be reverted by releasing and re-applying.
Blast Radius: community apply/resume flows — adopted orgs keep their owners (reviewer is downgraded from owner to admin, matching the reuse path), and organizations already bound to a proposal or another owner's unbound org keep the old conflict behavior.