{"record":{"id":"69d3a81dd7e2cd06","repo":"rohitg00/ai-engineering-from-scratch","slug":"secret-name-must-be-an-uppercase-environment-varia","errorCode":null,"errorMessage":"secret name must be an uppercase environment variable","messagePattern":"secret name must be an uppercase environment variable","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/13-application-security-and-secrets/code/main.py","lineNumber":107,"sourceCode":"        if not isinstance(url, str):\n            return Decision(False, \"url must be a string\", (\"schema_validation\",))\n        parsed = urlparse(url)\n        if parsed.scheme != \"https\" or parsed.hostname not in self.allowed_hosts:\n            return Decision(False, \"network destination is not allowed\", (\"network_allowlist\",))\n        return Decision(True, \"read-only request to allowed host\", (\"network_allowlist\", \"response_size_limit\"))\n\n\ndef redact(value: str) -> str:\n    \"\"\"Remove common secret assignments before a string reaches logs.\"\"\"\n    return SECRET_VALUE_PATTERN.sub(lambda match: f\"{match.group(1)}=[REDACTED]\", value)\n\n\nclass EnvironmentSecrets:\n    \"\"\"Return secret values to trusted code without logging or serialization helpers.\"\"\"\n\n    def require(self, name: str) -> str:\n        if not re.fullmatch(r\"[A-Z][A-Z0-9_]+\", name):\n            raise ValueError(\"secret name must be an uppercase environment variable\")\n        value = os.environ.get(name)\n        if not value:\n            raise RuntimeError(f\"required secret {name} is not configured\")\n        return value\n\n\ndef demo() -> dict[str, Any]:\n    gate = PolicyGate([\"/workspace/project\"], [\"api.example.test\"])\n    actions = [\n        Action(\"read_file\", {\"path\": \"/workspace/project/README.md\"}),\n        Action(\"read_file\", {\"path\": \"/workspace/project/.env\"}),\n        Action(\"run_command\", {\"command\": \"rm -rf /workspace/project\"}, approved=True),\n        Action(\"http_get\", {\"url\": \"https://api.example.test/status\"}),\n    ]\n    return {\"decisions\": [decision.__dict__ for decision in map(gate.evaluate, actions)]}\n\n\nif __name__ == \"__main__\":","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/13-application-security-and-secrets/code/main.py#L89-L125","documentation":"Error \"secret name must be an uppercase environment variable\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/13-application-security-and-secrets/code/main.py:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}