Skip to content

Bug: Circle Members Business Logic Returns Empty Results #256

@ngjunsiang

Description

@ngjunsiang

Summary

The circle members functionality returns an empty dictionary instead of the expected member data when listing circle members, causing assertion failures in integration tests.

Environment

  • Branch: 204-bug-campus-client-unauthorised-to-access-api
  • Test: test_circle_members in tests/integration/apps/test_models_circles.py
  • Component: Circle Models, Member Management
  • Storage Backend: Multiple (affects all backends)

Error Details

Stack Trace

AssertionError: 'uid-circle-f38b00e3' not found in {}

File "/workspaces/campus/tests/integration/apps/test_models_circles.py", line 101, in test_circle_members
    self.assertIn(member_id, members)

Test Flow That Fails

# Add member to parent circle
circle_obj.members.add(parent_id, member_id=member_id, access_value=1)

# List members - THIS RETURNS EMPTY DICT {}
members = circle_obj.members.list(parent_id)
self.assertIn(member_id, members)  # ← FAILS HERE

Root Cause Analysis

Symptoms

  1. circle_obj.members.add() appears to execute without errors
  2. circle_obj.members.list() returns an empty dictionary {} instead of member data
  3. Expected format: {member_id: access_value} but actual: {}

Potential Causes

  1. Storage Issue: Member data not being persisted correctly during add() operation
  2. Query Issue: list() method not querying the correct table/collection
  3. Data Format Issue: Member data stored in unexpected format or location
  4. Transaction Issue: Data not committed before retrieval
  5. Permission Issue: Insufficient access rights to view member data

Reproduction Steps

  1. Create a parent circle and member circle using circle factory
  2. Call circle_obj.members.add(parent_id, member_id=member_id, access_value=1)
  3. Call members = circle_obj.members.list(parent_id)
  4. Observe that members is an empty dictionary {}
  5. Expected: members should contain {member_id: 1}

Expected Behavior

  • After adding a member to a circle, members.list() should return the member
  • The returned format should be {member_id: access_value}
  • Member data should persist across operations within the same test

Investigation Needed

1. Member Storage Verification

Check if the add() operation actually persists data:

# After circle_obj.members.add(), verify storage directly
# Check database/storage for member records

2. Member Retrieval Logic

Examine the list() method implementation:

  • Verify SQL queries or database operations
  • Check table/collection names and schemas
  • Validate query parameters and filters

3. Circle Member Model Structure

Review the circle members data model:

  • Table schema for member relationships
  • Foreign key constraints
  • Data validation and format requirements

Files To Investigate

  • Circle model implementation in /workspaces/campus/campus/models/circle.py
  • Circle member management logic
  • Storage backend implementations for member operations
  • Test setup and data generation in test_models_circles.py

Impact

  • Severity: Medium
  • Component: Social Features, Circle Management
  • Affected Functionality: Circle membership, member access control, social relationships
  • Test Status: 1/5 integration tests failing due to this issue

Test Environment Context

  • This test passes initial circle creation and member ID generation
  • The failure occurs specifically in the member relationship management
  • Other circle operations may be unaffected

Next Steps

  1. Debug the members.add() method to verify data persistence
  2. Debug the members.list() method to verify data retrieval
  3. Check storage backend logs for any errors during member operations
  4. Verify circle member schema and table structure
  5. Add debug logging to trace data flow through member operations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions