Repository navigation
fix(frontend/recs): effectiveSavingsPct returns null when denominator is zero (closes #323) - #832
Conversation
…hout on_demand_cost (closes #323) For AWS RI/SP recs, EstimatedMonthlyOnDemandCost from Cost Explorer is the canonical denominator. When it is absent the reconstruction formula (monthly_cost + savings + amortized_upfront) diverges from the true on-demand baseline, producing misleadingly high percentages. Add a provider='aws' && !hasOnDemand guard that returns null so the UI renders the em-dash sentinel instead of a silently-wrong value. Azure rows retain the reconstruction fallback since older cached rows may legitimately omit on_demand_cost while remaining valid. Update reconstruction-path tests to use provider='azure' and add three new AWS-specific cases: no on_demand_cost, on_demand_cost=0, and valid on_demand_cost computes correctly.
|
@coderabbitai review |
|
Warning Review limit reached
More reviews will be available in 59 minutes and 25 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai review (Re-pinging: the prior full-review request on 2026-05-30 was acknowledged but no review body was posted, likely because of the org-level usage-credit exhaustion shown in the earlier rate-limit warning. PR has been CLEAN with CI green for several days; please post any findings so they can be addressed before merge.) |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get the PR diff
gh pr view 832 --repo LeanerCloud/CUDly --json title,body,files,additions,deletions,commits
echo "---DIFF---"
gh pr diff 832 --repo LeanerCloud/CUDlyLength of output: 9580 🏁 Script executed: #!/bin/bash
# Check what provider values are used in the codebase
rg -n "provider.*['\"]" frontend/src/ --type ts | grep -v "test" | grep -v ".d.ts" | head -40
echo "---"
# Check LocalRecommendation type definition for provider field
rg -n "provider" frontend/src/recommendations.ts | head -30
echo "---"
# Check if there are any GCP or other providers
rg -n "'gcp'\|'google'\|'azure'\|'aws'" frontend/src/ --type ts | head -30Length of output: 8143
|
Summary
effectiveSavingsPctnow returnsnullfor AWS rows whereon_demand_costis absent or zero, so the UI renders—instead of a value computed from the inaccurate reconstruction formula (monthly_cost + savings + amortized_upfront)on_demand_coston_demand_cost(null), AWS withon_demand_cost=0(null), AWS with validon_demand_cost(computes correctly)Root cause
For AWS RI/SP recs,
EstimatedMonthlyOnDemandCostfrom Cost Explorer is the canonical denominator. When it is absent from the CE response the backend logs a warning and stores zero, which the frontend converts tonullvia thenonZeroPtrconvention. The reconstruction formula then picksmonthly_cost + savings + amortized_upfrontas the denominator, which diverges from the true on-demand baseline and can produce percentages well above realistic savings ceilings (100%+).Test plan
cd frontend && npx jest --no-coverage --testPathPattern=recommendations.test.ts-- 322 tests passcd frontend && npx tsc --noEmit-- cleanon_demand_costrenders—in the Effective % column instead of an inflated valueon_demand_costpopulated continues to render the correct percentage