Two leaks in one small diff
builds on: Agents optimise the signal they can see, What the agent sees: its context
The fallback in `os.getenv` puts the live key into source, and into git history for good. It also hides missing config, because every machine silently uses that key. The new `log.debug` writes the `Bearer` token to wherever logs go once debug is on. **Later cost:** a permanent key in history, config errors that never fail loudly, and tokens in log stores. BETTER: keep `os.environ["PAY_API_KEY"]`, which raises `KeyError` when the variable is unset. Log the amount, never the headers.
// Python
--- a/billing/client.py
+++ b/billing/client.py
-API_KEY = os.environ["PAY_API_KEY"]
+API_KEY = os.getenv(
+ "PAY_API_KEY", "sk_live_51Hq8xT2eZvKa9")
def charge(amount):
headers = {"Authorization":
f"Bearer {API_KEY}"}
+ log.debug("charge %s", headers)
return post(URL, headers=headers)