Skip to content

chore(schema): mark provider API keys as secret in .env.schema.json#1010

Merged
Lightheartdevs merged 1 commit intoLight-Heart-Labs:mainfrom
yasinBursali:chore/schema-secret-flip
Apr 27, 2026
Merged

chore(schema): mark provider API keys as secret in .env.schema.json#1010
Lightheartdevs merged 1 commit intoLight-Heart-Labs:mainfrom
yasinBursali:chore/schema-secret-flip

Conversation

@yasinBursali
Copy link
Copy Markdown
Contributor

What

Flip "secret": true on five provider API-key entries in dream-server/.env.schema.json:

  • TARGET_API_KEY
  • ANTHROPIC_API_KEY
  • OPENAI_API_KEY
  • TOGETHER_API_KEY
  • LIVEKIT_API_KEY

Adds a parametric pytest locking the flag in as a regression guard.

Why

These keys were already being masked in dream config show (inline grep on key=) and in the dashboard-api GET /api/settings/env response (via _is_secret_field regex fallback on API_KEY). The schema is the intended authoritative source, and relying on name-pattern coincidence is fragile — any future rename that breaks the pattern would silently stop masking.

No runtime behavior change: both the schema-authoritative path and the regex fallback produce the same masked output today. This just routes through the primary path.

How

  • Added "secret": true as the third property on each of the five entries, matching the style of neighbors like LIVEKIT_API_SECRET and OPENCLAW_TOKEN.
  • Added a parametric pytest (test_production_schema_marks_provider_api_keys_secret) that loads the production schema (not a fixture) and asserts the flag on each of the five keys. Uses pathlib.Path(__file__).resolve().parents[4] for cross-platform path resolution.

Testing

  • jq . dream-server/.env.schema.json — parses cleanly
  • python3 -m pytest extensions/services/dashboard-api/tests/test_settings_env.py -v16/16 pass (11 pre-existing + 5 new parametric)
  • make lint — clean
  • Pre-commit hooks (gitleaks / private-key / large-file) — clean
  • Manual macOS: dream config show continues to mask these 5 keys (unchanged behavior)

Platform Impact

  • macOS: no runtime change (schema consumed identically)
  • Linux: no runtime change
  • Windows (WSL2): no runtime change

Schema is read by the dashboard-api container and validate-env.sh (jq) identically on all three platforms.

Five upstream-provider credentials (TARGET_API_KEY, ANTHROPIC_API_KEY,
OPENAI_API_KEY, TOGETHER_API_KEY, LIVEKIT_API_KEY) were missing the
"secret": true flag on their schema entries. Masking was working only
via a name-pattern fallback in dream config show and dashboard-api
_is_secret_field — the schema is the intended authoritative source.

Flipping the schema to be authoritative makes the primary path route
through schema intent rather than a regex accident, surviving any
future rename that might break the pattern match. No runtime behavior
change (both paths produce the same masked output today).

Adds a parametric pytest locking in "secret": true on each of the five
keys in the production schema as a regression guard.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Lightheartdevs Lightheartdevs merged commit b3473d6 into Light-Heart-Labs:main Apr 27, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants