[BE] Failures during applying pending promotions if the user gets added on a higher role up the hierarchy

Problem:

While applying pending promotions, we need to ensure we check billable status of the user before we return failed from the service:

eg: Bob is currently non-billable. Bob got queued to be added on SubGroup1 on Developer Role

  • If before Bob gets approved(or auto approved), Bob gets added on a Maintainer role on the parent Group (via LDAP, SAML, or by Admin themselves all whitelisted channels)
    • The above promotion made Bob a billable user.
  • When applying pending promotions the request will fail to apply because of this code check, basically the access needs to be greater than or equal to the access level they have been assigned on the parent group.
  • If this is the only promotion request for the user, the entire batch will fail as all pending promotions fail to apply(code)
  • This will keep the pending promotions request in "pending" state forever.

Solution

  • Since we allow even one success to be enough for marking all the pending promotions as success(even if all but 1 failed). (discussion point 2 on the original issue) and we return "Failed"(while keeping the records "pending") when "All" pending promotions could not be applied/failed. (discussion point 3 on the original issue)
    • with the above problem, even though the user is billable, the promotion request will remain in pending state indefinitely. Because no pending requests will get applied, so all requests would always fail.
  • As we return "success" once the user becomes billable even if applying pending promotions fails, maybe we should check if the user is already billable and return partial_success even if applying all pending promotions failed.
Edited Mar 24, 2025 by Suraj Tripathi
Assignee Loading
Time tracking Loading