fix: use correct meta key for user-deleted org tracking in V2#1536
Merged
Conversation
d3c1df6 to
844e3a5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
The V2 deleteAllOrganizationData function used a hardcoded meta key 'userDeletedOrgUid' instead of the 'userDeletedOrgs' constant used by MetaV2.getUserDeletedOrgUids(). This mismatch meant that after deleting an org, sync-default-organizations-v2 would not find it in the deleted list and would re-import it with is_home: false. Replace the inline meta logic with MetaV2.addUserDeletedOrgUid() to match V1's pattern. The call runs after transaction commit but before mutex release so sync-default-organizations-v2 cannot race in and re-import the org before the meta write completes. Also fix importOrganization's cleanup call to use removeUserDeletedOrgUid() instead of a raw destroy with the wrong key. Additionally, add is_home/isHome to the omit list in syncOrganizationMeta for both V1 and V2 to prevent datalayer store data from overwriting the home org flag.
844e3a5 to
917baa5
Compare
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
deleteAllOrganizationData: The function used a hardcoded'userDeletedOrgUid'meta key instead of the'userDeletedOrgs'constant defined inMetaV2. This meantsync-default-organizations-v2could not find the deleted org in its check and would re-import it withis_home: false, silently removing a participant's home org status. Replaced the inline meta logic withMetaV2.addUserDeletedOrgUid()to match V1's correct pattern.importOrganizationcleanup: TheMetaV2.destroy()call used the wrong meta key and tried to matchmeta_valueagainst a single orgUid when the actual value is a JSON array, so it never matched. Replaced withMetaV2.removeUserDeletedOrgUid().syncOrganizationMetafrom overwritingis_home/isHome: Added the home org flag to the_.omit()list in both V1 and V2syncOrganizationMeta, so datalayer store data can never overwrite this CADT-internal field.Root Cause
Investigated on the
cadt-participant1-testingk8s pod. The org was deleted via the API at 17:32 UTC, recorded undermeta_key = 'userDeletedOrgUid'. Within 40 seconds,sync-default-organizations-v2ran, checkedmeta_key = 'userDeletedOrgs'(different key), found nothing, and re-imported the org withis_home: false.Test plan
syncOrganizationMetadoes not overwriteis_homeeven if store data contains itNote
Medium Risk
Touches V2 org delete/import flows and mutex timing; a mistake could cause orgs to be incorrectly re-imported or skipped during background sync.
Overview
Fixes V2 user-deleted organization tracking by replacing ad-hoc
MetaV2.destroy/JSON-array manipulation withMetaV2.removeUserDeletedOrgUid()on import andMetaV2.addUserDeletedOrgUid()on delete, using the correctuserDeletedOrgsmeta key.Adjusts V2 deletion to write the “user deleted” marker while still holding mutexes (after the DB transaction) to prevent
sync-default-organizations-v2from re-importing an org between deletion and meta update.Prevents
syncOrganizationMetafrom overwriting the home-org flag by omittingisHome(V1) /is_home(V2) from store-driven updates.Written by Cursor Bugbot for commit 917baa5. This will update automatically on new commits. Configure here.