Skip to content

fix(backend): derive membership mock ancestor IDs from the channel row - #1048

Merged
flipvh merged 1 commit into
mainfrom
fix/membership-mocks-fk-ancestors
Aug 13, 2026
Merged

fix(backend): derive membership mock ancestor IDs from the channel row#1048
flipvh merged 1 commit into
mainfrom
fix/membership-mocks-fk-ancestors

Conversation

@flipvh

@flipvh flipvh commented Aug 13, 2026

Copy link
Copy Markdown
Member

Problem

mockChannelMembership filled ancestor channel-entity ID columns with invented UUIDs (via generateMockMembershipChannelIdColumns). That is fine for wire/response mocks, but the same output was used for database inserts, where invented ancestor IDs violate FK constraints. This surfaced in a fork (projectcampus) during its pnpm seed phase.

Fix

  • Add deriveMembershipChannelIdColumns: derives ancestor ID columns from the channel entity row itself (nullable ancestors stay null, overrideIds still win, target column stays identical to the denormalized channelId). Safe for inserts — no IDs are invented.
  • mockChannelMembership now uses the derive helper; ChannelRef accepts the ancestor ID columns off the row when present.
  • generateMockMembershipChannelIdColumns is kept for wire/response mocks only, with a doc warning never to insert its output.

Verification

  • pnpm --filter backend ts passes; pre-commit hook ran biome + full-repo typecheck + OpenAPI/SDK generation (SDK unchanged).
  • Change originated from debugging the projectcampus seed failure against a real database.

🤖 Generated with Claude Code

mockChannelMembership invented UUIDs for ancestor channel-entity ID
columns, so inserting its output violated FK constraints — surfaced by a
fork's pnpm seed. Add deriveMembershipChannelIdColumns, which reads
ancestor IDs off the channel entity row itself (overrides still win),
and keep the invented-ID generator for wire/response mocks only, with a
warning not to insert its output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@flipvh
flipvh merged commit c2ef748 into main Aug 13, 2026
9 checks passed
@flipvh
flipvh deleted the fix/membership-mocks-fk-ancestors branch August 13, 2026 20:30
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