You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
store: hub_approvals.access_group has no foreign key to access_groups #3
The column hub_approvals.access_group names an access group, but it has no foreign key to access_groups(name):
crates/aether-store/migrations/node/012_hub_approvals.sql: access_group TEXT NOT NULL DEFAULT 'friends'
crates/aether-store/migrations/node/011_access_groups.sql: access_group_members.group_name has REFERENCES access_groups(name) ON DELETE CASCADE
Thus the store accepts an approval for a group that does not exist. The store also lets a person delete a group while an open approval names it (NodeStore::delete_access_group in crates/aether-store/src/access_groups.rs).
Effect
The error comes late and in the wrong place. When the hub delivers the answer to an invite or a request, hub_sync gives approval.access_group to HostStep::Sign (crates/aether/src/hub_sync.rs), and the node then joins the person to that group. add_access_group_member returns StoreError::NotFound, and the join fails during sync, long after the person deleted the group or after a wrong name was written.
Decision needed
A foreign key changes behaviour, so it needs a rule for a deleted group. Possible rules:
ON DELETE RESTRICT: a group with an open approval cannot be deleted. The admin page and MCP must show why, and must name the open approvals.
ON DELETE CASCADE: deleting a group also deletes its open approvals. The node then does not sign a grant when the hub answers.
Move to the default group: deleting a group moves its open approvals to friends. This needs a trigger or an explicit update in delete_access_group, because ON DELETE SET DEFAULT only works if friends always exists.
Work
Choose the rule.
Add a migration that rebuilds hub_approvals with the foreign key (SQLite cannot add a foreign key to an existing table). Existing rows that name a missing group need a rule too: drop them or move them to friends.
Make put_hub_approval reject a missing group with a clear error.
Add store tests for: an approval for a missing group, and the delete of a group with an open approval.
Activity