FAILURE MAP
← Case archive

FA-9636 / Configuration / Open access

Environment variable projection: Empty environment values fall through to defaults · case 01

Empty environment values fall through to defaults.

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

ROOT CAUSE

The implementation substitutes if environment.get(key): for if key in environment:, so empty environment values fall through to defaults.

VERIFIED REPAIR

Check presence independently of value truthiness.

Unsuccessful approach: The attempted repair substitutes if environment.get(key) not in (None, ''):. Fixture 3 still yields {'PORT': '80'} instead of {'PORT': ''}.

Case contract

For declared variable names return exact present environment value, otherwise explicit default including empty values. Required missing values report missing; optional missing values are omitted. Prefix is prepended before lookup.

Why this case matters

An offline model of environment variable projection, suitable for testing build and release tooling without external services.

1 / The failure

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

N = 1
observations = []
def solve(declarations, environment, prefix):
    result = {}
    for name, default, required in declarations:
        key = prefix + name
        if environment.get(key): result[name] = environment[key]
        elif default is not None: result[name] = default
        elif required: result[name] = 'missing'
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1', solve([], {}, 'APP_'), {})
check('fixture 2', solve([('PORT', None, True)], {'APP_PORT': '0'}, 'APP_'), {'PORT': '0'})
check('fixture 3', solve([('PORT', '80', True)], {'APP_PORT': ''}, 'APP_'), {'PORT': ''})
check('fixture 4', solve([('PORT', '', True)], {}, 'APP_'), {'PORT': ''})
check('fixture 5', solve([('PORT', None, True)], {}, 'APP_'), {'PORT': 'missing'})
check('fixture 6', solve([('PORT', None, False)], {}, 'APP_'), {})
check('fixture 7', solve([('PORT', '80', False)], {}, 'APP_'), {'PORT': '80'})
check('fixture 8', solve([('PORT', '80', True)], {'PORT': '90'}, 'APP_'), {'PORT': '80'})
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
fixture 1{}{}Passed
fixture 2{'PORT': '0'}{'PORT': '0'}Passed
fixture 3{'PORT': '80'}{'PORT': ''}Failed
fixture 4{'PORT': ''}{'PORT': ''}Passed
fixture 5{'PORT': 'missing'}{'PORT': 'missing'}Passed
fixture 6{}{}Passed
fixture 7{'PORT': '80'}{'PORT': '80'}Passed
fixture 8{'PORT': '80'}{'PORT': '80'}Passed

SHA-256 / 4f114ae5c6d2c20f1eeb6d7d03a9f7371829cdfba1a391f17044444c32d764c7

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(declarations, environment, prefix):
    result = {}
    for name, default, required in declarations:
        key = prefix + name
        if environment.get(key) not in (None, ''): result[name] = environment[key]
        elif default is not None: result[name] = default
        elif required: result[name] = 'missing'
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1', solve([], {}, 'APP_'), {})
check('fixture 2', solve([('PORT', None, True)], {'APP_PORT': '0'}, 'APP_'), {'PORT': '0'})
check('fixture 3', solve([('PORT', '80', True)], {'APP_PORT': ''}, 'APP_'), {'PORT': ''})
check('fixture 4', solve([('PORT', '', True)], {}, 'APP_'), {'PORT': ''})
check('fixture 5', solve([('PORT', None, True)], {}, 'APP_'), {'PORT': 'missing'})
check('fixture 6', solve([('PORT', None, False)], {}, 'APP_'), {})
check('fixture 7', solve([('PORT', '80', False)], {}, 'APP_'), {'PORT': '80'})
check('fixture 8', solve([('PORT', '80', True)], {'PORT': '90'}, 'APP_'), {'PORT': '80'})
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
fixture 1{}{}Passed
fixture 2{'PORT': '0'}{'PORT': '0'}Passed
fixture 3{'PORT': '80'}{'PORT': ''}Failed
fixture 4{'PORT': ''}{'PORT': ''}Passed
fixture 5{'PORT': 'missing'}{'PORT': 'missing'}Passed
fixture 6{}{}Passed
fixture 7{'PORT': '80'}{'PORT': '80'}Passed
fixture 8{'PORT': '80'}{'PORT': '80'}Passed

SHA-256 / 80b1c220df2f8f98a55402c093ad892e59b15c34542298e0aa5210d38170c45c

3 / The verified repair

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

N = 1
observations = []
def solve(declarations, environment, prefix):
    result = {}
    for name, default, required in declarations:
        key = prefix + name
        if key in environment: result[name] = environment[key]
        elif default is not None: result[name] = default
        elif required: result[name] = 'missing'
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1', solve([], {}, 'APP_'), {})
check('fixture 2', solve([('PORT', None, True)], {'APP_PORT': '0'}, 'APP_'), {'PORT': '0'})
check('fixture 3', solve([('PORT', '80', True)], {'APP_PORT': ''}, 'APP_'), {'PORT': ''})
check('fixture 4', solve([('PORT', '', True)], {}, 'APP_'), {'PORT': ''})
check('fixture 5', solve([('PORT', None, True)], {}, 'APP_'), {'PORT': 'missing'})
check('fixture 6', solve([('PORT', None, False)], {}, 'APP_'), {})
check('fixture 7', solve([('PORT', '80', False)], {}, 'APP_'), {'PORT': '80'})
check('fixture 8', solve([('PORT', '80', True)], {'PORT': '90'}, 'APP_'), {'PORT': '80'})
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
fixture 1{}{}Passed
fixture 2{'PORT': '0'}{'PORT': '0'}Passed
fixture 3{'PORT': ''}{'PORT': ''}Passed
fixture 4{'PORT': ''}{'PORT': ''}Passed
fixture 5{'PORT': 'missing'}{'PORT': 'missing'}Passed
fixture 6{}{}Passed
fixture 7{'PORT': '80'}{'PORT': '80'}Passed
fixture 8{'PORT': '80'}{'PORT': '80'}Passed

SHA-256 / 49862693840bf82a6bde42dcd4a36b72a4730be0c206287b424f5c752a899d5e

Verification & scope

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:38:31.656948+00:00.

Case digest / edb7e72bd3b4f413fe2f47429f19f9f912db98b705b058d1302da9ace999a150