Skip to content

fix(aws): daily coverage call sets Granularity with GroupBy, which Cost Explorer rejects #68

Description

@cristim

Summary

The daily-sparkline coverage call sets both Granularity and GroupBy on GetReservationCoverage, which the API documents as mutually exclusive. Every real call returns a ValidationException, which the caller logs at warning level and swallows, so the per-row usage-history feature is dead in production while collection looks healthy. Mock-backed tests stay green because none of them assert Granularity on this input.

Location

providers/aws/recommendations/usage_history.go:85 at 3c0f8ac94048a2c36fce5ccddee54e6c4849a5cd

Failure scenario

The GetReservationCoverage SDK operation doc states "If GroupBy is set, Granularity can't be set." fetchDailyCoverage sets both, so every real call returns a ValidationException. AttachDailyUsageHistory logs the error at WARN and continues, so the entire per-row usage-history feature is dead in production while the collection looks healthy. No test asserts Granularity on this input (the three GranularityDaily assertions in the package are in ondemand_series_test.go and sp_coverage_test.go, whose operations do accept it), which is why mock-backed tests stay green. The sibling path in coverage.go correctly omits Granularity when it sets GroupBy.

Evidence

input := &costexplorer.GetReservationCoverageInput{
    TimePeriod:  &types.DateInterval{...},
    Granularity: types.GranularityDaily,
    GroupBy: []types.GroupDefinition{
        {Type: types.GroupDefinitionTypeDimension, Key: aws.String(string(types.DimensionInstanceType))},
    },
    Filter:  dailyUsageFilter(serviceFilter, region),
    Metrics: []string{"Hour"},
}

Suggested fix

Drop the Granularity field (the response is already per-day when the time period is daily-resolvable), and assert its absence in the test so the pair cannot be reintroduced.


Found by the 2026-09-02 codebase audit, finding A07-010, reported by one reviewer and independently confirmed by a second. Full report: docs/audits/codebase-audit-2026-09-02.md.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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