[master] [Subscription Billing] Infinite loop in CalculateBillingPeriod when HarmonizeNextBillingTo caps at stale "Next Billing To" date#8830
Conversation
| PreviousBillingPeriodEnd := 0D; | ||
| while (BillingPeriodEnd < BillingDate) and | ||
| ((BillingPeriodEnd < ServiceCommitment."Subscription Line End Date") or (ServiceCommitment."Subscription Line End Date" = 0D)) | ||
| do |
There was a problem hiding this comment.
The new loop-progress guard (BillingPeriodEnd > PreviousBillingPeriodEnd) correctly prevents an infinite loop, but when it fires it exits silently: the var output parameter BillingPeriodEnd is left holding the non-advancing value returned by CalculateNextBillingToDateForServiceCommitment, and the caller receives no signal distinguishing a normal exit (billing date or end-date boundary reached) from an abnormal one (the inner function failed to advance the period).
In subscription billing, a silently incorrect BillingPeriodEnd can produce wrong invoice amounts or missed billing lines.
Recommendation:
- after the loop, detect the abnormal case — for example by checking whether the guard condition would have allowed another iteration but didn't — and raise an
Erroror emit a telemetry signal so the failure surface is observable.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Copilot PR ReviewIteration 1 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 0 knowledge-backed · 1 agent findings. Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
AB#640056
Bug 640056: [master] [ALL-E][Subscription Billing] Infinite loop in CalculateBillingPeriod when HarmonizeNextBillingTo caps at stale "Next Billing To" date