SKY-L016 · Logic and resilience
Undefined config
A feature flag is read from the environment with no default, such as os.getenv("ENABLE_NEW_PRICING"), and the file never declares it. Coding agents often write such checks for settings that no deployment defines.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
Nobody knows the flag exists, so the new code path never runs, or runs by accident: environment values are strings, and "false" or "0" are both true in an if. Setting ENABLE_NEW_PRICING=false turns the new pricing on.
What Skylos flags
"""Price a shopping cart.""" import os from shop import legacy_pricing, new_pricing def cart_total(cart): if os.getenv("ENABLE_NEW_PRICING"): return new_pricing.total(cart) return legacy_pricing.total(cart)What Skylos leaves alone
"""Price a shopping cart.""" import os from shop import legacy_pricing, new_pricing def cart_total(cart): if os.getenv("ENABLE_NEW_PRICING", "false") == "true": return new_pricing.total(cart) return legacy_pricing.total(cart)Why Skylos leaves it alone
The read gives a default, so the flag has a defined value when the environment does not set it, and the comparison with "true" turns the string into a real yes or no.
How Skylos decides
- Runs with
--qualityon Python files. Looks at calls writtenos.getenv("NAME")andos.environ.get("NAME")with a literal name. - Only names that start with
ENABLE_,DISABLE_,USE_,FEATURE_,FLAG_orTOGGLE_are checked; other settings are left alone, and so are well-known variables such asDEBUG,PATHorDATABASE_URL. - Skips a read with a default other than
None, a module-level declaration that assigns the read to the same name (ENABLE_X = os.getenv("ENABLE_X")), and a name that also appears asos.environ["NAME"]anywhere in the file. - Reports MEDIUM on the line of the call. Other files,
.envfiles and deployment settings are not read.
How to fix it
Declare the flag once, with a default and a real boolean, and use that constant. The name now has one place where it is defined and documented.
"""Price a shopping cart.""" import os from shop import legacy_pricing, new_pricing Added: ENABLE_NEW_PRICING = os.getenv("ENABLE_NEW_PRICING", "false").lower() == "true" Added: def cart_total(cart):Removed: if os.getenv("ENABLE_NEW_PRICING"):Added: if ENABLE_NEW_PRICING: return new_pricing.total(cart) return legacy_pricing.total(cart)When it can be wrong
- A flag that a settings module or
.envfile in another place does define is reported, because only the current file is read. - A module-level
ENABLE_X = os.getenv("ENABLE_X")is accepted even though it still turns"false"into a true value.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put the marker on the line of the
os.getenv()call.Python if os.getenv("ENABLE_NEW_PRICING"): # skylos: ignore[SKY-L016] set in Helm values[tool.skylos] ignore = ["SKY-L016"]turns the rule off for the project.