Skip to content

fix(reactions): human pod-access falls back to Mongo membership (PG pod_members drift)#746

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/reaction-access-mongo-fallback
Jul 24, 2026
Merged

fix(reactions): human pod-access falls back to Mongo membership (PG pod_members drift)#746
lilyshen0722 merged 1 commit into
mainfrom
fix/reaction-access-mongo-fallback

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Bug (2026-07-24, launch — the real "count stuck at 1")

Reaction counts appeared frozen at 1 for everyone but the reactor. Root cause: callerHasPodAccess gates human reactions solely on PG pod_members:

SELECT 1 FROM pod_members WHERE pod_id = $1 AND user_id = $2

But PG pod_members is a lazily-synced mirror of Mongo pod.members. Community auto-join (ensureUserInCommunityPod) and other join paths write Mongo only. So members whose PG row never synced got 403 — and the frontend swallows reaction errors, so it just looked like the count wouldn't move.

Measured on Commonly HQ: 66 Mongo members, 1 in PG pod_members → 65 of 66 members silently 403'd on every reaction. The only member who could react was the single one present in PG, so counts never exceeded 1.

Fix

Give the human path the Mongo fallback the agent path already has: after the PG fast-path misses, check Mongo pod.members (the source of truth).

  • Also backfilled HQ's PG pod_members out-of-band for the immediate fix (verified live: a previously-403'd member reacted → 👍:2).
  • The code fix makes it robust for all pods, future joins, and members not yet in PG.

Test

Two new cases in reactionController.test.js: human in Mongo-but-not-PG → allowed; human in neither → 403. Suite green (15 tests).

Related drift (follow-up worth filing)

ensureUserInCommunityPod (and other join paths) should mirror membership to PG pod_members; 5 HQ members aren't even in the PG users table (registration doesn't sync users to PG — same family as #743). The Mongo fallback covers reaction access regardless, but other PG-gated reads may want the same treatment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES

…rift)

callerHasPodAccess gated human reactions ONLY on PG pod_members, but that
table is a lazily-synced mirror of Mongo pod.members — community auto-join
(ensureUserInCommunityPod) and other join paths write Mongo only. Result:
members whose PG row never synced got 403, silently (frontend swallows it),
so reaction counts appeared stuck at 1. 2026-07-24: Commonly HQ had 66 Mongo
members but 1 in PG pod_members → 65/66 could not react.

Fix: after the PG fast-path misses, fall back to Mongo pod.members (the source
of truth) — the same fallback the agent path already had. (Also backfilled HQ's
PG pod_members out-of-band for the immediate fix; this makes it robust for all
pods + future joins + users not yet in PG.)

Test: two new cases — human in Mongo-but-not-PG is allowed; human in neither → 403.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES
@lilyshen0722
lilyshen0722 merged commit 994f9c0 into main Jul 24, 2026
10 checks passed
@lilyshen0722
lilyshen0722 deleted the fix/reaction-access-mongo-fallback branch July 24, 2026 08:28
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