Skip to content

fix(customer-portal): show downloadables to members via benefit grants#12393

Open
pieterbeulque wants to merge 1 commit into
mainfrom
claude/cool-darwin-uih3jl
Open

fix(customer-portal): show downloadables to members via benefit grants#12393
pieterbeulque wants to merge 1 commit into
mainfrom
claude/cool-darwin-uih3jl

Conversation

@pieterbeulque

@pieterbeulque pieterbeulque commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

I believe this was never finished, and I think it makes more sense to remove member_id from downloadables instead of duplicating a downloadables row per member, whereas for e.g. license keys it was required to generate a license key per member.

Generated description

Members in the customer portal could not see downloadables. The repository
filtered by Downloadable.member_id == member.id, but a downloadable row is
unique per (customer, file, benefit) and shared across a customer's members,
so its member_id can only ever reference one of them. On seat-based products
the same file/benefit is granted to several members, they collide on that one
row, and only the first-granted member gets attributed — everyone else sees
nothing.

A downloadables benefit defines its files at the benefit level, so every
member holding an active grant for that benefit is entitled to the same files.
Gate member visibility on the member's benefit grants (the source of truth for
per-member entitlement, which already works) instead of on the shared
Downloadable.member_id column. This also fixes legacy rows that never had
member_id backfilled. No migration required.


Summary by cubic

Fixes member visibility of downloadables in the customer portal by checking active benefit grants instead of Downloadable.member_id. Restores access for seat-based products and legacy rows without member_id.

  • Bug Fixes
    • Filter member results by customer_id and active, non-deleted benefit grants.
    • Supports shared rows across members (seat-based products) and legacy rows without member_id.
    • Added API tests for member with grant, without grant, and shared-row collision; no migration needed.

Written for commit d2f1057. Summary will update on new commits.

Review in cubic

Members in the customer portal could not see downloadables. The repository
filtered by `Downloadable.member_id == member.id`, but a downloadable row is
unique per (customer, file, benefit) and shared across a customer's members,
so its member_id can only ever reference one of them. On seat-based products
the same file/benefit is granted to several members, they collide on that one
row, and only the first-granted member gets attributed — everyone else sees
nothing.

A downloadables benefit defines its files at the benefit level, so every
member holding an active grant for that benefit is entitled to the same files.
Gate member visibility on the member's benefit grants (the source of truth for
per-member entitlement, which already works) instead of on the shared
Downloadable.member_id column. This also fixes legacy rows that never had
member_id backfilled. No migration required.
@pieterbeulque pieterbeulque requested review from a team and frankie567 as code owners June 15, 2026 19:25
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orbit Ready Ready Preview, Comment Jun 15, 2026 7:25pm
polar Ready Ready Preview, Comment Jun 15, 2026 7:25pm
polar-sandbox Ready Ready Preview, Comment Jun 15, 2026 7:25pm
polar-test Ready Ready Preview, Comment Jun 15, 2026 7:25pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

OpenAPI Changes

No changes detected in the OpenAPI schema.

@pieterbeulque pieterbeulque requested a review from psincraian June 15, 2026 19:27

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@github-actions

Copy link
Copy Markdown
Contributor

Preview Environment
URL: https://polar-preview-vm.taildbff7b.ts.net/pr-12393
API: https://polar-preview-vm.taildbff7b.ts.net/pr-12393/v1/
Logs: backend
SHA: d2f10570945f98a59a1a5b9366dbcde396794b30

@psincraian psincraian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to discuss this approach. I thought I removed the uniqueness of customer_id in every benefit type, but seems I was wrong.

My main idea is that benefits are member aware mainly, as we grant benefits for each member. For me the downloadable should follow the same pattern as the others, so we should replace the uniqueness to be member and benefit_id aware only.

@pieterbeulque

Copy link
Copy Markdown
Contributor Author

I'm fine with that too. What are the steps involved in that approach then? I imagine it'll need a backfill?

@psincraian

Copy link
Copy Markdown
Contributor

that will become more a burden, yes 🥲 as it's a shitty thing that I forget, I can fix it.

The idea would be to remove the customer uniqueness and add a member uniqueness. Then do a backfill of missing downloads (looping through customer members)

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.

3 participants