Skip to main content

SKY-L016 · Logic and resilience

Undefined config

Medium

The catalog gives no severity for this rule; the detector always reports MEDIUM.

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

shop/pricing.py · PythonReported on line 9
"""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

shop/pricing.py · Python
"""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

  1. Runs with --quality on Python files. Looks at calls written os.getenv("NAME") and os.environ.get("NAME") with a literal name.
  2. Only names that start with ENABLE_, DISABLE_, USE_, FEATURE_, FLAG_ or TOGGLE_ are checked; other settings are left alone, and so are well-known variables such as DEBUG, PATH or DATABASE_URL.
  3. 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 as os.environ["NAME"] anywhere in the file.
  4. Reports MEDIUM on the line of the call. Other files, .env files 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.

shop/pricing.py · Python · the fix, against the flagged file
"""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 .env file 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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.