Skip to content

Commit b3473d6

Browse files
Merge pull request #1010 from yasinBursali/chore/schema-secret-flip
chore(schema): mark provider API keys as secret in .env.schema.json
2 parents 9055007 + 87c34f8 commit b3473d6

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

dream-server/.env.schema.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,23 @@
5454
},
5555
"TARGET_API_KEY": {
5656
"type": "string",
57-
"description": "API key for Privacy Shield upstream target (set to LITELLM_KEY in lemonade mode)"
57+
"description": "API key for Privacy Shield upstream target (set to LITELLM_KEY in lemonade mode)",
58+
"secret": true
5859
},
5960
"ANTHROPIC_API_KEY": {
6061
"type": "string",
61-
"description": "Anthropic API key (cloud/hybrid modes)"
62+
"description": "Anthropic API key (cloud/hybrid modes)",
63+
"secret": true
6264
},
6365
"OPENAI_API_KEY": {
6466
"type": "string",
65-
"description": "OpenAI API key (cloud/hybrid modes)"
67+
"description": "OpenAI API key (cloud/hybrid modes)",
68+
"secret": true
6669
},
6770
"TOGETHER_API_KEY": {
6871
"type": "string",
69-
"description": "Together AI API key (optional)"
72+
"description": "Together AI API key (optional)",
73+
"secret": true
7074
},
7175
"WEBUI_SECRET": {
7276
"type": "string",
@@ -407,7 +411,8 @@
407411
},
408412
"LIVEKIT_API_KEY": {
409413
"type": "string",
410-
"description": "LiveKit API key"
414+
"description": "LiveKit API key",
415+
"secret": true
411416
},
412417
"LIVEKIT_API_SECRET": {
413418
"type": "string",

dream-server/extensions/services/dashboard-api/tests/test_settings_env.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,32 @@ def test_render_env_preserves_extras_with_empty_values():
309309
rendered = _render_env_from_values(values)
310310
assert "TENSOR_SPLIT=" in rendered
311311
assert "GPU_UUID=GPU-abc123" in rendered
312+
313+
314+
# --- Production schema secret-flag coverage ---
315+
316+
317+
@pytest.mark.parametrize(
318+
"key",
319+
[
320+
"TARGET_API_KEY",
321+
"ANTHROPIC_API_KEY",
322+
"OPENAI_API_KEY",
323+
"TOGETHER_API_KEY",
324+
"LIVEKIT_API_KEY",
325+
],
326+
)
327+
def test_production_schema_marks_provider_api_keys_secret(key):
328+
"""Credential API keys in the production schema must carry ``secret: true``.
329+
330+
Regression guard: without the explicit flag, masking in both
331+
``dream config show`` and ``GET /api/settings/env`` falls back to a
332+
name-pattern match. The schema should be the authoritative source.
333+
"""
334+
import pathlib
335+
336+
schema_path = pathlib.Path(__file__).resolve().parents[4] / ".env.schema.json"
337+
schema = json.loads(schema_path.read_text(encoding="utf-8"))
338+
entry = schema["properties"].get(key)
339+
assert entry is not None, f"schema missing entry for {key}"
340+
assert entry.get("secret") is True, f"{key} must have 'secret': true in .env.schema.json"

0 commit comments

Comments
 (0)