zeroclaw-labs/zeroclaw · error

Brave API key not configured (decrypted value is empty)

Error message

Brave API key not configured (decrypted value is empty)

What it means

Provider configuration guard in reload_brave_api_key: a Brave API key entry exists in config but decrypts to an empty string, so Brave search cannot authenticate. This is a secret-store misconfiguration (empty or corrupted encrypted value), not a network failure.

Solutions

  1. Set the Brave Search API key: `zeroclaw config set tools.web_search.brave.api_key <key>` or re-run `zeroclaw quickstart`.
  2. Verify the configured encrypted secret decrypts to a non-empty value; re-enter the key if it was stored empty.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zeroclaw-tools/src/web_search_tool.rs:166 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/686baa9d1644a2de. Report an issue: GitHub.

Appendix: source

Thrown at crates/zeroclaw-tools/src/web_search_tool.rs:166

            .ok_or_else(|| {
                ::zeroclaw_log::record!(
                    ERROR,
                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Reject)
                        .with_outcome(::zeroclaw_log::EventOutcome::Failure)
                        .with_attrs(::serde_json::json!({"search_provider": "brave"})),
                    "web_search: Brave API key not configured"
                );
                anyhow::Error::msg("Brave API key not configured")
            })?;

        // Decrypt if necessary.
        if zeroclaw_config::secrets::SecretStore::is_encrypted(&raw_key) {
            let zeroclaw_dir = self.config_path.parent().unwrap_or_else(|| Path::new("."));
            let store =
                zeroclaw_config::secrets::SecretStore::new(zeroclaw_dir, self.secrets_encrypt);
            let plaintext = store.decrypt(&raw_key)?;
            if plaintext.is_empty() {
                anyhow::bail!("Brave API key not configured (decrypted value is empty)");
            }
            Ok(plaintext)
        } else {
            Ok(raw_key)
        }
    }

    async fn search_duckduckgo(&self, query: &str) -> anyhow::Result<String> {
        self.search_duckduckgo_at("https://html.duckduckgo.com/html/", query)
            .await
    }

    /// Inner DuckDuckGo request implementation, parameterized on the endpoint URL
    /// so request-flow tests can target a local mock server. Production calls
    /// always go through [`Self::search_duckduckgo`].
    async fn search_duckduckgo_at(
        &self,
        endpoint_url: &str,

View on GitHub (pinned to 88bb9c8533)