Skip to content

bug(billing): plan product listings return the product title as its behavior #1831

Description

@rohilsurana

What

BillingPlanRepository.ListWithProducts (internal/store/postgres/billing_plan_repository.go:380) builds its SELECT with:

prd.Col("title").As("product_behavior"),

So the product_behavior column is filled from the product's title, not its behavior column. The billing_products table does have a real behavior column (migration 20231231021142_add_feature_behavior, mapped at billing_product_repository.go:52). As a result every product returned by ListPlans, GetPlan, and the new ListAllPlans reports behavior equal to its title.

The same block also sources plan_deleted_at from the product table (billing_plan_repository.go:374, prd.Col("deleted_at").As("plan_deleted_at")), which looks wrong for a plan's deleted-at and is worth reviewing at the same time.

Impact

Any consumer that reads a product's behavior from a plan listing gets the title instead of the behavior. Pre-existing; it was surfaced while reviewing the new ListAllPlans endpoint.

Fix

Select prd.Col("behavior").As("product_behavior") and review the plan_deleted_at source. Add a repository test that asserts the behavior round-trips.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions