{"record":{"id":"a3736d74c16b3df1","repo":"nautechsystems/nautilus_trader","slug":"standard-secret-var-not-found-in-config-or-envir","errorCode":null,"errorMessage":"{standard_secret_var} not found in config or environment","messagePattern":"(.+?) not found in config or environment","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/credential.rs","lineNumber":106,"sourceCode":"        };\n\n    // Futures: soft deprecation (warn + fallback),\n    // Spot/Margin: hard error on removed env vars.\n    let is_futures = matches!(\n        product_type,\n        BinanceProductType::UsdM | BinanceProductType::CoinM\n    );\n\n    let api_key = config_api_key\n        .or_else(|| std::env::var(standard_key_var).ok())\n        .or_else(|| resolve_deprecated_var(deprecated_key_var, standard_key_var, is_futures))\n        .ok_or_else(|| anyhow::anyhow!(\"{standard_key_var} not found in config or environment\"))?;\n\n    let api_secret = config_api_secret\n        .or_else(|| std::env::var(standard_secret_var).ok())\n        .or_else(|| resolve_deprecated_var(deprecated_secret_var, standard_secret_var, is_futures))\n        .ok_or_else(|| {\n            anyhow::anyhow!(\"{standard_secret_var} not found in config or environment\")\n        })?;\n\n    Ok((api_key, api_secret))\n}\n\nfn resolve_deprecated_var(\n    deprecated_var: &str,\n    standard_var: &str,\n    allow_fallback: bool,\n) -> Option<String> {\n    if deprecated_var.is_empty() {\n        return None;\n    }\n\n    let value = std::env::var(deprecated_var).ok()?;\n\n    if allow_fallback {\n        log::warn!(","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/common/credential.rs#L88-L124","documentation":"resolve_credentials resolved the API key but not the secret: neither the config api_secret nor the standard environment variable named in the message (e.g. BINANCE_API_SECRET, BINANCE_TESTNET_API_SECRET, BINANCE_FUTURES_TESTNET_API_SECRET, BINANCE_DEMO_API_SECRET) is set. The adapter needs both halves of the credential pair to sign requests.","triggerScenarios":"Config or environment supplies only the key (half-configured credential), or the secret env var name does not match the configured environment/product type while the key var does.","commonSituations":"Key exported but secret forgotten or truncated by shell quoting; secret stored in a secret manager that was not attached at deploy; mixed live/testnet variable names between key and secret; reliance on removed *_ED25519_* secret vars.","solutions":["Export the exact secret variable named in the message alongside the key","Check the secret was not mangled by shell quoting/expansion (compare length against the value in the Binance console)","Or pass api_secret directly in the client config instead of the environment","Migrate deprecated *_ED25519_API_SECRET names to the standard names"],"exampleFix":"# before\nexport BINANCE_API_KEY=...   # secret missing\n\n# after\nexport BINANCE_API_KEY=...\nexport BINANCE_API_SECRET=...","handlingStrategy":"validation","validationCode":"let key = std::env::var(\"BINANCE_API_SECRET\");\nif key.is_err() {\n    anyhow::bail!(\"BINANCE_API_SECRET missing - set it alongside the API key before starting the client\");\n}","typeGuard":"fn credentials_complete(env_vars: &[&str]) -> bool {\n    env_vars.iter().all(|v| std::env::var(v).is_ok())\n}","tryCatchPattern":"match resolve_credentials(config_key, config_secret, environment, product_type) {\n    Ok((k, s)) => build_client(k, s),\n    Err(e) if e.to_string().contains(\"API_SECRET\") => { /* alert: half-configured credential */ Err(e) }\n    Err(e) => Err(e),\n}","preventionTips":["Set key and secret together from the same source in one step","After loading secrets, sanity-check their lengths against the values shown in the Binance console","Automate config checks in CI so a missing secret fails the deploy, not the first live request"],"tags":["binance","credentials","environment-variables","configuration","startup"],"backgroundTag":"missing-api-credentials","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}