Skip to content

fix(recommendations): AWS 1-year-term recs missing — only 3yr recs render when both exist #188

@cristim

Description

@cristim

Background

Reported by @cristim: the Recommendations page only shows AWS recs with term = 3 years. The 1-year-term variants never appear, even though Cost Explorer returns recs at both term lengths and the term-column filter has a 1 Year value to filter by.

Likely root cause

internal/scheduler/scheduler.go:827 derives the recommendation ID from a 5-tuple that omits Term:

key := fmt.Sprintf("%s:%s:%s:%s:%s", providerName, rec.Service, rec.Region, rec.ResourceType, rec.PaymentOption)

Cost Explorer returns 1yr and 3yr recs for the same (provider, service, region, resource_type, payment) cell as separate Recommendation objects. Both hash to the same recordID. Whichever lands in records second wins (or, if a downstream stage dedupes by ID via a Map/Set, whichever runs first wins). The user sees only one of them — the 3yr variant in this report, suggesting the iteration order in the AWS provider client puts 3yr after 1yr in the slice that feeds the scheduler conversion.

Same root cause as the Azure-checkbox-double-toggle bug filed separately, but the symptom here is "missing data" rather than "duplicate selection" — when the dedup happens at storage / response-build time, only one rec is rendered; when it happens at render time (both rows reach the DOM with the same data-rec-id), the user gets the toggle bug. Both are downstream of the same broken hash.

Repro

  1. Configure AWS with a workload that has Cost Explorer recommendations available (EC2, RDS, ElastiCache — anything with a 1yr + 3yr offering at the same payment).
  2. Force-refresh recommendations from Settings.
  3. Open the Recommendations tab.
  4. Observe: every visible AWS rec has Term = 3 Years. Open the term column-filter popover; "1 Year" appears in the distinct-values list only when there happen to be 1yr-only recs for cells without a 3yr competitor.

Acceptance criteria

  • 1-year-term AWS recs and 3-year-term AWS recs both appear when both exist for the same (provider, service, region, resource_type, payment) cell.
  • A scheduler-level test seeds two common.Recommendation instances differing only in term, runs them through the conversion, and asserts both records survive with distinct IDs.
  • An end-to-end manual verification: pick a known cell with both terms in Cost Explorer and confirm both rows render in the UI.

Suggested fix path

Same fix as the Azure-checkbox bug: add Term (and ideally CloudAccountID) to the hash key at scheduler.go:827. One change closes both bugs.

⚠ Verify before estimating effort: same persisted-state caveat as the sibling issue — historical purchase rows / plans may reference old IDs.

References

  • internal/scheduler/scheduler.go:817-846
  • AWS provider rec construction: providers/aws/services/*/client.go (look for Term field assignment per service)
  • Sibling bug: Azure checkbox double-toggle (likely shared root cause)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions