Skip to content

Conversation

@skwowet
Copy link
Member

@skwowet skwowet commented Dec 10, 2025

Note

Adds a Temporal workflow and CLI to detect activityRelations with wrong memberId and move them to the verified member by username per platform.

  • Script Executor Worker:
    • New Temporal workflow workflows/fix-activityRelations-memberId to batch-fix activityRelations with incorrect memberId across all PlatformType values.
    • Activities: add findMembersWithWrongActivityRelations, findMemberIdByUsernameAndPlatform, and moveActivityRelations wired into activities.ts.
    • CLI script src/bin/fix-activityRelations-memberId.ts for cursor-based scanning of verified username identities and moving relations; added npm script fix-activity-relations-memberId.
    • Types: add IFixActivityRelationsMemberIdArgs for batch/test-run control and platform iteration.
  • Data Access Layer:
    • MemberRepository: add findMembersWithIncorrectActivityRelations and getMemberIdByUsernameAndPlatform queries.
    • Use moveActivityRelationsWithIdentityToAnotherMember via writer connection to transfer relations.

Written by Cursor Bugbot for commit b8b732e. This will update automatically on new commits. Configure here.

@skwowet skwowet self-assigned this Dec 10, 2025
@skwowet skwowet marked this pull request as ready for review December 11, 2025 08:07
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

1 similar comment
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@skwowet skwowet force-pushed the script/fix-activityRelations-memberId branch from 86e3ae6 to 02b87bb Compare December 12, 2025 13:20
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

correctMemberId,
record.username,
record.platform,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing guard causes infinite loop when IDs match

The workflow calls moveActivityRelations(record.memberId, correctMemberId, ...) without checking if record.memberId === correctMemberId. Due to a race condition where data changes between the two queries (findMembersWithIncorrectActivityRelations and findMemberIdByUsernameAndPlatform), these values could be equal. When fromId === toId, the underlying moveActivityRelationsWithIdentityToAnotherMember function enters an infinite loop because the UPDATE doesn't change the memberId value, so the subquery keeps matching the same rows indefinitely. This would waste resources until Temporal's 30-minute activity timeout triggers.

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

record.username,
record.platform,
)
}),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test-run mode still executes database writes in workflow

When args.testRun is true, the code logs the intended operation but then still calls moveActivityRelations because it's placed outside the if block. The bin script version correctly uses an if-else pattern to skip the write during test runs, but the workflow version logs the message and then unconditionally executes the write operation anyway. This defeats the purpose of the test-run flag and could cause unintended data modifications.

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

record.platform,
)
}),
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Workflow doesn't comprehensively fix objectMemberId issues

The workflow queries only for memberId inconsistencies using findMembersWithIncorrectActivityRelations, but moveActivityRelationsWithIdentityToAnotherMember also attempts to fix objectMemberId. The objectMemberId update uses fromId (the wrong memberId) as the filter, so it only fixes objectMemberId when it coincidentally equals the wrong memberId value. The bin script correctly handles this with separate queries for both memberId and objectMemberId issues, but the workflow is missing the objectMemberId query loop, leaving many objectMemberId fixes incomplete.

Additional Locations (1)

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant