Spaces:
Sleeping
Sleeping
Claude Code commited on
Commit ·
d9c8cec
1
Parent(s): ca9b351
Claude Code: Fix worker env injection - remove empty API key defaults that interfere with HF Space secrets
Browse files
app.py
CHANGED
|
@@ -284,12 +284,15 @@ class WorkerManager:
|
|
| 284 |
pass
|
| 285 |
|
| 286 |
def _get_worker_env(self) -> dict[str, str]:
|
| 287 |
-
"""Build environment for worker process.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
worker_env = os.environ.copy()
|
| 289 |
worker_env["PYTHONPATH"] = "/app:" + worker_env.get("PYTHONPATH", "")
|
| 290 |
worker_env["CAIN_IS_WORKER"] = "true"
|
| 291 |
-
worker_env.setdefault("CLAUDE_API_KEY", "")
|
| 292 |
-
worker_env.setdefault("ANTHROPIC_API_KEY", "")
|
| 293 |
return worker_env
|
| 294 |
|
| 295 |
async def shutdown(self):
|
|
|
|
| 284 |
pass
|
| 285 |
|
| 286 |
def _get_worker_env(self) -> dict[str, str]:
|
| 287 |
+
"""Build environment for worker process.
|
| 288 |
+
|
| 289 |
+
CRITICAL: Uses os.environ.copy() which automatically inherits all
|
| 290 |
+
HF Space secrets (HF_TOKEN, OPENAI_API_KEY, OPENROUTER_API_KEY, etc).
|
| 291 |
+
DO NOT set empty defaults - that can interfere with secret inheritance.
|
| 292 |
+
"""
|
| 293 |
worker_env = os.environ.copy()
|
| 294 |
worker_env["PYTHONPATH"] = "/app:" + worker_env.get("PYTHONPATH", "")
|
| 295 |
worker_env["CAIN_IS_WORKER"] = "true"
|
|
|
|
|
|
|
| 296 |
return worker_env
|
| 297 |
|
| 298 |
async def shutdown(self):
|