Skip to content

🔒 Stop printing the Valohai LLM API key in debug logs - #44

Merged
akx merged 1 commit into
mainfrom
fix/40-redact-valohai-llm-api-key
Nov 19, 2026
Merged

akx merged 1 commit into
mainfrom
fix/40-redact-valohai-llm-api-key

Conversation

@petterir

Copy link
Copy Markdown
Collaborator

Fixes #40.

conduit -v logs the loaded config with its Debug representation, and ValohaiLlmConfig derived Debug, so the Valohai LLM API key was printed in full on the "config loaded" line. ValohaiLlmConfig now implements Debug by hand:

before: ... valohai_llm: ValohaiLlmConfig { api_key: "test-key-do-not-leak-12345", url: "https://llm.valohai.com" } ...
after:  ... valohai_llm: ValohaiLlmConfig { api_key: "<redacted>", url: "https://llm.valohai.com" } ...
no key: ... valohai_llm: ValohaiLlmConfig { api_key: "<empty>", url: "https://llm.valohai.com" } ...

The line still shows whether a key was picked up, which is the useful part when debugging forwarding.

For the reviewer

  • The issue also suggested secrecy::SecretString. This PR doesn't use it: the hand-written Debug covers every {:?} of the config without a new dependency or a change to the field type that sync.rs reads.
  • The tests check that no 4-character piece of the key appears in the Debug output of ValohaiLlmConfig or of a whole Config, for a key from the TOML file and for one from VALOHAI_LLM_API_KEY.
  • Other places a secret can reach the log, such as request headers at -vv, are tracked in conduit -vv prints provider API keys, and two other log paths can leak secrets #42 and not changed here.

Testing

cargo fmt --all --check, cargo clippy --workspace --tests --locked and cargo test --workspace --locked pass. The old and new binaries were also run with a dummy key; with the fix, the key appears nowhere in the output at -v or -vv.

🤖 Generated with Claude Code

`conduit -v` logs the loaded config with its `Debug` representation, and
`ValohaiLlmConfig` derived `Debug`, so `valohai_llm.api_key` was printed
in full on the "config loaded" line, whether the key came from
`conduit.toml` or `VALOHAI_LLM_API_KEY`.

`ValohaiLlmConfig` now implements `Debug` by hand. The line shows
`api_key: "<redacted>"` when a key is set and `api_key: "<empty>"` when it
is not, so you can still tell whether a key was picked up, and `url` is
shown as before.

Fixes #40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change that redacts the Valohai LLM API key from configuration debug logs.

No open issues 🎉

What changed in this PR

Addresses #40 by preventing the Valohai LLM API key from appearing in configuration debug logs, while preserving whether a key is set. Other secret-logging paths remain outside this PR’s scope and are tracked in #42.

Changes:

  • Replaces derived Debug with a custom implementation showing <redacted> or <empty> instead of the key.
  • Adds regression tests for TOML-loaded and environment-loaded keys, nested configuration formatting, and empty keys.
File Description
crates/​core/​src/​config.rs Redacts the API key in debug output and adds regression tests.

Review effort: Balanced

@akx
akx merged commit fac0ee9 into main Nov 19, 2026
9 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.

conduit -v prints the Valohai LLM API key in plain text

3 participants