Skip to content

fix(aws): request daily reservation coverage by instance filter - #160

Merged
cristim merged 1 commit into
mainfrom
fix/68-daily-coverage
Sep 29, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/68-daily-coverage

Conversation

@cristim

@cristim cristim commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Daily usage history sent both DAILY granularity and GroupBy to Cost Explorer, which rejects that combination. Keep DAILY, filter to the recommendation's exact instance type, and read each day's Total coverage so recommendations receive ordered usage points.

Closes #68

Validation: the real SDK/local HTTP regression failed against the original request and passes after the fix. It covers request shape on both pages, shuffled daily totals, tuple batching, missing days, absent totals and API errors. Removing DAILY or INSTANCE_TYPE independently makes it fail. The recommendations race suite, AWS module build and CI-pinned golangci-lint pass with Go 1.26.6 and GOWORK=off. This is local SDK/HTTP fixture verification against the official API contract; no live AWS call was made.

Independent review: gpt-6-astra completed two clean implementation passes and approved final SHA 3dc630dae83a5bf0e3b8f8be2c6919660054bf55 after fetching it into an independent clone, confirming patch identity and rerunning focused race tests. The reviewer independently reproduced the pre-fix failure and passed the restored full recommendations race suite. Verdict: approved, subject to required hosted CI. CodeRabbit is waived for this session. Normal commit hooks passed. Added-comment ratio: 0.8%.

Summary by CodeRabbit

  • Bug Fixes
    • Daily usage history now reflects reservation coverage for the matching service, region, and instance type.
    • Incomplete coverage periods are excluded, and daily totals are handled consistently across paginated results.

@cristim cristim added triaged Item has been triaged urgency/this-sprint Within the current sprint priority/p1 Next up; this sprint severity/high Significant harm impact/many Affects most users effort/xs Trivial / one-liner type/bug Defect labels Sep 29, 2026
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 7f2c6ff3-b8c4-4905-9d7a-2e4de2a83d31

📥 Commits

Reviewing files that changed from the base of the PR and between a32fd1a and 3dc630d.

📒 Files selected for processing (2)
  • providers/aws/recommendations/usage_history.go
  • providers/aws/recommendations/usage_history_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

Daily usage history now filters reservation coverage by service, region, and instance type. The request omits grouping and retains daily granularity. The result mapping reads each period’s total coverage percentage and skips periods missing a start date or total.

Changes

AWS daily usage history

Layer / File(s) Summary
Daily coverage request and result mapping
providers/aws/recommendations/usage_history.go, providers/aws/recommendations/usage_history_test.go
The request filters by service, region, and instance type without grouping. The mapping uses each period’s total coverage percentage and skips periods without a start date or total. SDK-backed tests cover request parameters, pagination, results, errors, duplicate recommendations, and batching.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 3dc63

The change corrects daily coverage requests while preserving ordered usage history and existing failure handling. No actionable merge-blocking risk remains; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #68 requests removing Granularity from the daily GetReservationCoverage request and adding a regression assertion that it remains absent. This PR removes GroupBy instead, keeps `Granularit… Remove Granularity from the daily GetReservationCoverage input and update the SDK regression test to assert that the field is absent. Keep the related exact-instance-type filtering and total-coverage assertions if required by this PR.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The production changes stay within daily reservation-coverage behavior: they change request filtering, response extraction, and pagination handling. The new HTTP regression test covers that request an…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: requesting daily AWS reservation coverage with an instance-type filter.
Full details: Linked Issues check

Explanation

Issue #68 requests removing Granularity from the daily GetReservationCoverage request and adding a regression assertion that it remains absent. This PR removes GroupBy instead, keeps Granularity: types.GranularityDaily, and tests for GranularityDaily. The request no longer combines the two rejected fields, but it does not implement the linked issue's requested coding change.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@cristim
cristim merged commit 7e2ad63 into main Sep 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/many Affects most users priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant