Repository navigation
[T3697] Household: the members sent by Connect replace the household's members - #2217
Merged
Merged
Conversation
…s members The member list was searched by name in all the households of the database: every member with the same name was moved into the household being updated and overwritten, so families got duplicated members (wrong number of brothers and sisters on MyCompassion) and others lost theirs. The list received from Connect now replaces the members of the household. The migration reloads the household mapping. Assisted-by: claude-opus-5-5, medium, claude-code
[Medium impact] This PR appears safe to merge. Reviews (1) · Last reviewed commit: "[T3697] Household: the members sent by C..." · Reviewed by Greptile |
Danielgergely
approved these changes
Nov 17, 2026
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.
Problem
MyCompassion shows wrong family information for some children. Example: KE091300438 shows 6 brothers and 14 sisters, while Connect has 5 brothers and 3 sisters. Its household had 23 members instead of 10 (Lucy Njeri 11 times, Esther Wairimu 3 times, Peter Mbugua twice).
Cause
The "Household" mapping looked up each member of
BeneficiaryHouseholdMemberListby name in all the household members of the database (search_relational_record+search_key: name). Every member with the same name was linked to the household being updated and overwritten with the received values. So:In the database, this entry was also set to "append" by hand, so old members were never removed. The logic is old (same before T3151); duplicated rows exist since 2017.
Local copy of 26/10: 7,608 households with duplicated members (16,140 extra rows), 3,348 with wrong brother/sister counts, 1,806 of the 15,441 sponsored children affected.
Changes
child_compassion18.0.1.1.3:static/mappings/household.json: the member list is written in "overwrite" mode without searching by name. The list received from Connect replaces the members of the household (old members are deleted,ondelete="cascade"). Sponsored siblings are still linked to their child by global ID (Household Member mapping).migrations/18.0.1.1.3/post-migration.py: reloadshousehold.json(mappings are only loaded at install).tests/test_household_members.py: the same family received three times keeps its members; a member removed in Connect disappears; another family with a member of the same name is untouched. Two of the three fail with the old mapping.Not in this PR
The existing wrong households are only corrected when Connect sends them again. A reload of the households of all sponsored children from Connect should be planned separately (procedure for the IT).
Tests
After deployment
Upgrade
child_compassion.