FAILURE MAP
← Case archive

FA-73876 / Feature flag rollout bucketing / Open access

Weighted variant allocation: Buckets past the total receive no variant · case 01

When weights sum below 100 percent, users in the leftover buckets get no variant at all.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The function returns None after the loop instead of the last positively weighted variant.

VERIFIED REPAIR

Return the last positively weighted variant for buckets beyond the running total.

Unsuccessful approach: Returning the final declared variant can hand remainder traffic to a zero-weight arm.

Case contract

variants is an ordered list of [name, weight percent with at most two decimals]; bucket is an integer in [0, 10000). Walk variants in declared order, skipping non-positive weights, adding round(weight * 100) to a running total, and return the first variant whose total exceeds the bucket. Buckets beyond the total go to the last positively weighted variant; with none, None.

Why this case matters

Variant splits decide which arm of a flag a user receives and must honour declared weights exactly.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(variants, bucket):
    acc = 0
    last = None
    for name, weight in variants:
        if weight <= 0:
            continue
        last = name
        acc += round(weight * 100)
        if bucket < acc:
            return name
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('bucket at first cumulative edge goes to second arm',
   [[['control', 50], ['treatment', 50]], 5000],
   'treatment'),
  ('bucket just below first edge stays in first arm',
   [[['control', 50], ['treatment', 50]], 4999],
   'control'),
  ('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 1', [[['green', 1.15], ['holdout', 0], ['alpha', 1.15], ['blue', 50]], 1135], 'blue'),
  ('weight table sample 2', [[['blue', 50], ['treatment', 10]], 2986], 'blue')],
 [('bucket just below first edge stays in first arm',
   [[['control', 50], ['treatment', 50]], 4999],
   'control'),
  ('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 6',
   [[['alpha', 0.29], ['holdout', 12.5], ['blue', 0.57], ['treatment', 0]], 204],
   'holdout'),
  ('weight table sample 27',
   [[['green', 33.33], ['holdout', 0], ['control', 0], ['alpha', -5]], 3333],
   'green')],
 [('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 9',
   [[['blue', 0], ['alpha', 0.57], ['green', 4.35], ['treatment', -5]], 4555],
   'green'),
  ('weight table sample 11', [[['holdout', 12.5], ['blue', 12.5], ['alpha', 0.57]], 2500], 'alpha'),
  ('weight table sample 51', [[['alpha', 10], ['holdout', 10], ['blue', 0.29]], 5446], 'blue')],
 [('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('three way split middle arm', [[['a', 33.33], ['b', 33.33], ['c', 33.34]], 5000], 'b'),
  ('weight table sample 4', [[['green', 12.5], ['treatment', 0.29]], 7991], 'treatment'),
  ('weight table sample 16', [[['green', 0.57], ['alpha', 12.5], ['control', 25]], 1307], 'control'),
  ('weight table sample 27',
   [[['green', 33.33], ['holdout', 0], ['control', 0], ['alpha', -5]], 3333],
   'green')],
 [('bucket at first cumulative edge goes to second arm',
   [[['control', 50], ['treatment', 50]], 5000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('three way split middle arm', [[['a', 33.33], ['b', 33.33], ['c', 33.34]], 5000], 'b'),
  ('weight table sample 21', [[['green', 33.33], ['treatment', 0]], 0], 'green'),
  ('weight table sample 29', [[['holdout', -5], ['treatment', -5], ['blue', 4.35]], 435], 'blue'),
  ('weight table sample 48', [[['treatment', 0], ['green', -5], ['blue', 0]], 0], None)]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
bucket at first cumulative edge goes to second armtreatmenttreatmentPassed
bucket just below first edge stays in first armcontrolcontrolPassed
zero weight arm is never selectedtreatmenttreatmentPassed
trailing zero weight arm does not absorb remainderNonetreatmentFailed
declared order beats alphabetical orderzetazetaPassed
no positive weights yields NoneNoneNonePassed
weight table sample 1bluebluePassed
weight table sample 2bluebluePassed

SHA-256 / ef82597405f4545c2517f6be1c14b5c829e27ca5bcd0d836e1770dcbcfb45d37

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(variants, bucket):
    acc = 0
    last = None
    for name, weight in variants:
        if weight <= 0:
            continue
        last = name
        acc += round(weight * 100)
        if bucket < acc:
            return name
    return variants[-1][0] if variants else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('bucket at first cumulative edge goes to second arm',
   [[['control', 50], ['treatment', 50]], 5000],
   'treatment'),
  ('bucket just below first edge stays in first arm',
   [[['control', 50], ['treatment', 50]], 4999],
   'control'),
  ('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 1', [[['green', 1.15], ['holdout', 0], ['alpha', 1.15], ['blue', 50]], 1135], 'blue'),
  ('weight table sample 2', [[['blue', 50], ['treatment', 10]], 2986], 'blue')],
 [('bucket just below first edge stays in first arm',
   [[['control', 50], ['treatment', 50]], 4999],
   'control'),
  ('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 6',
   [[['alpha', 0.29], ['holdout', 12.5], ['blue', 0.57], ['treatment', 0]], 204],
   'holdout'),
  ('weight table sample 27',
   [[['green', 33.33], ['holdout', 0], ['control', 0], ['alpha', -5]], 3333],
   'green')],
 [('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 9',
   [[['blue', 0], ['alpha', 0.57], ['green', 4.35], ['treatment', -5]], 4555],
   'green'),
  ('weight table sample 11', [[['holdout', 12.5], ['blue', 12.5], ['alpha', 0.57]], 2500], 'alpha'),
  ('weight table sample 51', [[['alpha', 10], ['holdout', 10], ['blue', 0.29]], 5446], 'blue')],
 [('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('three way split middle arm', [[['a', 33.33], ['b', 33.33], ['c', 33.34]], 5000], 'b'),
  ('weight table sample 4', [[['green', 12.5], ['treatment', 0.29]], 7991], 'treatment'),
  ('weight table sample 16', [[['green', 0.57], ['alpha', 12.5], ['control', 25]], 1307], 'control'),
  ('weight table sample 27',
   [[['green', 33.33], ['holdout', 0], ['control', 0], ['alpha', -5]], 3333],
   'green')],
 [('bucket at first cumulative edge goes to second arm',
   [[['control', 50], ['treatment', 50]], 5000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('three way split middle arm', [[['a', 33.33], ['b', 33.33], ['c', 33.34]], 5000], 'b'),
  ('weight table sample 21', [[['green', 33.33], ['treatment', 0]], 0], 'green'),
  ('weight table sample 29', [[['holdout', -5], ['treatment', -5], ['blue', 4.35]], 435], 'blue'),
  ('weight table sample 48', [[['treatment', 0], ['green', -5], ['blue', 0]], 0], None)]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
bucket at first cumulative edge goes to second armtreatmenttreatmentPassed
bucket just below first edge stays in first armcontrolcontrolPassed
zero weight arm is never selectedtreatmenttreatmentPassed
trailing zero weight arm does not absorb remainderofftreatmentFailed
declared order beats alphabetical orderzetazetaPassed
no positive weights yields NonebNoneFailed
weight table sample 1bluebluePassed
weight table sample 2bluebluePassed

SHA-256 / fbc51d161cf6ad49bd659c56d3257e80fd988dc6dc24aa19017fbb36316decc1

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(variants, bucket):
    acc = 0
    last = None
    for name, weight in variants:
        if weight <= 0:
            continue
        last = name
        acc += round(weight * 100)
        if bucket < acc:
            return name
    return last
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('bucket at first cumulative edge goes to second arm',
   [[['control', 50], ['treatment', 50]], 5000],
   'treatment'),
  ('bucket just below first edge stays in first arm',
   [[['control', 50], ['treatment', 50]], 4999],
   'control'),
  ('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 1', [[['green', 1.15], ['holdout', 0], ['alpha', 1.15], ['blue', 50]], 1135], 'blue'),
  ('weight table sample 2', [[['blue', 50], ['treatment', 10]], 2986], 'blue')],
 [('bucket just below first edge stays in first arm',
   [[['control', 50], ['treatment', 50]], 4999],
   'control'),
  ('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 6',
   [[['alpha', 0.29], ['holdout', 12.5], ['blue', 0.57], ['treatment', 0]], 204],
   'holdout'),
  ('weight table sample 27',
   [[['green', 33.33], ['holdout', 0], ['control', 0], ['alpha', -5]], 3333],
   'green')],
 [('zero weight arm is never selected', [[['control', 0], ['treatment', 100]], 0], 'treatment'),
  ('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('weight table sample 9',
   [[['blue', 0], ['alpha', 0.57], ['green', 4.35], ['treatment', -5]], 4555],
   'green'),
  ('weight table sample 11', [[['holdout', 12.5], ['blue', 12.5], ['alpha', 0.57]], 2500], 'alpha'),
  ('weight table sample 51', [[['alpha', 10], ['holdout', 10], ['blue', 0.29]], 5446], 'blue')],
 [('trailing zero weight arm does not absorb remainder',
   [[['control', 40], ['treatment', 40], ['off', 0]], 9000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('three way split middle arm', [[['a', 33.33], ['b', 33.33], ['c', 33.34]], 5000], 'b'),
  ('weight table sample 4', [[['green', 12.5], ['treatment', 0.29]], 7991], 'treatment'),
  ('weight table sample 16', [[['green', 0.57], ['alpha', 12.5], ['control', 25]], 1307], 'control'),
  ('weight table sample 27',
   [[['green', 33.33], ['holdout', 0], ['control', 0], ['alpha', -5]], 3333],
   'green')],
 [('bucket at first cumulative edge goes to second arm',
   [[['control', 50], ['treatment', 50]], 5000],
   'treatment'),
  ('declared order beats alphabetical order', [[['zeta', 10], ['alpha', 90]], 500], 'zeta'),
  ('fractional weight 0.29 covers 29 buckets', [[['tiny', 0.29], ['rest', 99.71]], 28], 'tiny'),
  ('no positive weights yields None', [[['a', 0], ['b', 0]], 10], None),
  ('three way split middle arm', [[['a', 33.33], ['b', 33.33], ['c', 33.34]], 5000], 'b'),
  ('weight table sample 21', [[['green', 33.33], ['treatment', 0]], 0], 'green'),
  ('weight table sample 29', [[['holdout', -5], ['treatment', -5], ['blue', 4.35]], 435], 'blue'),
  ('weight table sample 48', [[['treatment', 0], ['green', -5], ['blue', 0]], 0], None)]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
bucket at first cumulative edge goes to second armtreatmenttreatmentPassed
bucket just below first edge stays in first armcontrolcontrolPassed
zero weight arm is never selectedtreatmenttreatmentPassed
trailing zero weight arm does not absorb remaindertreatmenttreatmentPassed
declared order beats alphabetical orderzetazetaPassed
no positive weights yields NoneNoneNonePassed
weight table sample 1bluebluePassed
weight table sample 2bluebluePassed

SHA-256 / 04b37cd1063a7de9224c80afd071b8d9e27e4893ece147db6a83ca53f3b82b83

Verification & scope

A deterministic toy flag-evaluation model with a stipulated contract; it does not reproduce any vendor SDK byte for byte. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:48:51.480843+00:00.

Case digest / a892e2386ecc8566e6f8a78e79286d6875e41c1a5e5539534c183cbd9ebc6f59