Repository navigation
fix(scheduler): propagate ambient fallback GetRecommendations error - #1230
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe scheduler fallback path now returns an error when the fallback recommendation fetch fails after an empty primary result. AWS recommendation converter comments and tests now describe unsupported values as empty strings rather than default enum values. ChangesScheduler fallback error propagation
AWS converter comment updates
Estimated code review effort: 2 (Simple) | ~10 minutes Related issue
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
…y-enum behaviour The converters_test.go docstrings still claimed the legacy wrappers "silently default to NoUpfront/OneYear/SevenDays" -- the same stale claim that #1230 just fixed in converters.go. The wrappers actually return the empty ("") enum on unrecognized values, which Cost Explorer rejects with a validation error. This mirrors the converters.go doc-only fix into the sibling test file so the source-of-truth comment is consistent across both. No behaviour change; no test assertions modified.
Adversarial review (PR #1230)Reviewed against the COR-05 finding (#1168) and the risk surfaces in the brief: silent fallback path, error-type preservation, errgroup ctx propagation, caller behaviour with the new error, "no recommendations" vs "fetch failed" distinguishability, and sibling silent-fallback patterns. Fix is correct, narrowly scoped, well tested. One in-scope docstring sync pushed ( Verified
Fix pushed
Follow-up filedNone. The RI-path empty-enum issue is already tracked by #865/#1075. The pre-existing UNSTABLE stateFour failing checks ( VerdictLGTM. CR re-ping below. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
…y-enum behaviour The converters_test.go docstrings still claimed the legacy wrappers "silently default to NoUpfront/OneYear/SevenDays" -- the same stale claim that #1230 just fixed in converters.go. The wrappers actually return the empty ("") enum on unrecognized values, which Cost Explorer rejects with a validation error. This mirrors the converters.go doc-only fix into the sibling test file so the source-of-truth comment is consistent across both. No behaviour change; no test assertions modified.
|
Rebased onto origin/main (31 commits ahead). Conflict resolved in Gates passed:
New head: aeabbc8 |
|
@coderabbitai review |
Rate Limit Exceeded
|
The AWS ambient/self-account path in fetchAndConvert retried with the global default term/payment when the primary sweep returned zero recommendations, but discarded the retry's error (recs, _ =). A misconfigured DefaultPayment/DefaultTerm or a Cost Explorer failure on that fallback was therefore invisible: the operator saw zero recommendations with no signal. Handle the error and fail loud: wrap it with provider, term, payment, and lookback context and return it so the collection surfaces the failure instead of silently presenting an empty result. Also fix the stale doc comments on the deprecated converters in providers/aws/recommendations/converters.go: they claimed to "silently default" to NoUpfront/OneYear/SevenDays, but since the *E variants were introduced they return the empty enum, which Cost Explorer rejects. Regression test TestScheduler_CollectAWSRecommendations_FallbackError asserts the fallback error is propagated with context and no recommendations are returned; it fails on the pre-fix code. Closes #1168
…y-enum behaviour The converters_test.go docstrings still claimed the legacy wrappers "silently default to NoUpfront/OneYear/SevenDays" -- the same stale claim that #1230 just fixed in converters.go. The wrappers actually return the empty ("") enum on unrecognized values, which Cost Explorer rejects with a validation error. This mirrors the converters.go doc-only fix into the sibling test file so the source-of-truth comment is consistent across both. No behaviour change; no test assertions modified.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Merged on the substantive CI signal (all Lint/Unit/Integration/Security/Build/E2E/Validate-Terraform green; only the non-blocking tflint pre-commit flake red) closes #1168. |
Problem
COR-05 from the 2026-06-10 codebase review: in
internal/scheduler/scheduler.go, the AWS ambient/self-account path (fetchAndConvert) retriesGetRecommendationswith the global default term/payment when the primary sweep returns zero recommendations, but discards the retry's error entirely (recs, _ =). A misconfiguredDefaultPayment/DefaultTermor a Cost Explorer failure on the fallback is permanently invisible; the operator just sees zero recommendations with no signal. The deprecated converters feeding the params also carried stale doc comments claiming they "silently default" to NoUpfront/OneYear/SevenDays, when they actually return the empty enum (which Cost Explorer rejects with a validation error).Fix
fetchAndConvertnow handles the fallback error and fails loud: the error is wrapped with provider, term, payment, and lookback context and returned, so the failure surfaces through the normal collection error path (failed-provider accounting, freshness banner, logs) instead of silently presenting an empty result.Deprecated:doc comments inproviders/aws/recommendations/converters.goto describe the actual empty-enum behavior (doc-only; the converter behavior itself is unchanged and out of scope here).Provider-factory wiring is intentionally untouched (tracked separately as ARCH-12 LeanerCloud/cloud-commitments-platform#41).
Test evidence
TestScheduler_CollectAWSRecommendations_FallbackErrorreplicates the real scenario: primaryGetAllRecommendationsreturns zero recs, the fallbackGetRecommendationsreturns a CE validation error. It asserts the error is propagated (errors.Ison the cause), carries the fallback/term/payment context, and that no recommendations are returned.go build ./...clean;go test ./internal/scheduler/... ./providers/aws/recommendations/...: 70 passed.Closes #1168
Summary by CodeRabbit
Bug Fixes
Tests
Documentation