State that Module 17's .env loader must use setdefault, or Part D's override demo silently fails #29
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The lab hands generation of the critical loader to the AI ("load the .env file with a few lines of plain Python"). Part D's headline demo (
APP_ENV=staging python sync.pyoverriding .env'sdev) only works if the loader usesos.environ.setdefaultso real/CLI env wins. A very common AI-generated minimal loader uses plain assignmentos.environ[key]=value, in which case .env overwrites the command-line override, the URL doesn't change, the "same code, different environment" point silently fails, and nothing tells the learner why. This precedence is load-bearing yet unexplained.Evidence
modules/17-secrets-config-and-environments/README.mdPart C prompt (~line 335): "load the .env file with a few lines of plain Python." Model answer (~line 352) usesos.environ.setdefault(...). Part D (~lines 388-389, 397): "Watch the backend URL change with APP_ENV while the source never does."Reproduced: plain-assignment loader →
APP_ENV=stagingresolves todev.Why it matters
The module's payoff silently fails for a plausible AI output, and the Check-for-understanding test fails, with no diagnostic — against the explain-the-why voice and honesty promise.
Proposed change
os.environ.setdefault(...)so real/CLI env wins over the file (matches the real-world dotenv defaultoverride=False).Acceptance criteria
setdefaultprecedence makes Part D's override work.Affected files
modules/17-secrets-config-and-environments/README.mdReferences
Source finding F44 (realVotes 3/3).
Filed from an adversarial multi-agent course review (217 raw findings → 54 adversarially-verified survivors). Scoped for manual review; intentionally not auto-assigned to an agent.