{"record":{"id":"ea4da5fe76b89dc9","repo":"nautechsystems/nautilus_trader","slug":"missing-api-credentials-set-deribit-environment-v","errorCode":null,"errorMessage":"Missing API credentials; set Deribit environment variables","messagePattern":"Missing API credentials; set Deribit environment variables","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/adapters/deribit/src/execution.rs","lineNumber":508,"sourceCode":"            self.await_session_tasks().await?;\n            self.session_tasks\n                .start_generation()\n                .map_err(|e| anyhow::anyhow!(\"Failed to start Deribit session generation: {e}\"))?;\n        } else if self.ws_client.is_active() {\n            self.ws_client\n                .close()\n                .await\n                .context(\"failed to close stale Deribit WebSocket\")?;\n        }\n        let ws_client = self.ws_client.clone();\n        let setup_guard =\n            TaskGroupGuard::new(&[&self.session_tasks, &self.pending_tasks], move || {\n                ws_client.begin_shutdown();\n            });\n\n        // Check if credentials are available before requesting account state\n        if !self.config.has_api_credentials() {\n            anyhow::bail!(\"Missing API credentials; set Deribit environment variables\");\n        }\n\n        // Set account ID for order/fill reports\n        self.ws_client.set_account_id(self.core.account_id);\n\n        // Fetch and cache instruments in both HTTP client and WebSocket client\n        if !self.core.instruments_initialized() {\n            for product_type in &self.config.product_types {\n                let instruments = self\n                    .http_client\n                    .request_instruments(DeribitCurrency::ANY, Some(*product_type))\n                    .await\n                    .with_context(|| {\n                        format!(\"failed to request instruments for {product_type:?}\")\n                    })?;\n\n                if instruments.is_empty() {\n                    log::warn!(\"No instruments returned for {product_type:?}\");","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/execution.rs#L490-L526","documentation":"After establishing the WebSocket connection, the Deribit execution client checks config.has_api_credentials() before requesting account state. If no API credentials are configured, it bails, because trading operations require authenticated access to Deribit's private API.","triggerScenarios":"Calling connect() on the Deribit execution client when no API key/secret environment variables (Deribit client id/secret) are set in the environment or provided in the config.","commonSituations":"Running in an environment where DERIBIT_* env vars were never exported (CI, containers, new machine); pointing at live env but credentials only configured for testnet (or vice versa); typo'd env var names; .env file not loaded.","solutions":["Set the Deribit API credential environment variables (client id and client secret) before connect, e.g. export DERIBIT_CLIENT_ID=... and DERIBIT_CLIENT_SECRET=...","If credentials are passed via config, ensure DeribitExecClientConfig includes them (or the env vars it reads)","Verify the credentials match the selected environment (test vs live) and are valid on Deribit","Confirm the process env actually contains the vars (print/debug or shell `env | grep DERIBIT`) — .env files often aren't auto-loaded"],"exampleFix":"// before: connecting with no credentials in env\nexec_client.connect().await?;\n// after: ensure credentials are present first\nstd::env::set_var(\"DERIBIT_CLIENT_ID\", client_id);\nstd::env::set_var(\"DERIBIT_CLIENT_SECRET\", client_secret);\nexec_client.connect().await?;","handlingStrategy":"validation","validationCode":"fn has_deribit_creds() -> bool {\n    std::env::var(\"DERIBIT_CLIENT_ID\").is_ok() && std::env::var(\"DERIBIT_CLIENT_SECRET\").is_ok()\n}\nif !has_deribit_creds() { return Err(anyhow::anyhow!(\"export DERIBIT_CLIENT_ID / DERIBIT_CLIENT_SECRET first\")); }","typeGuard":null,"tryCatchPattern":"match exec_client.connect().await {\n    Err(e) if e.to_string().contains(\"Missing API credentials\") => {\n        load_env_file();\n        exec_client.connect().await\n    }\n    other => other,\n}","preventionTips":["Export DERIBIT API env vars in shell profiles, CI secrets, and container env before startup","Explicitly load .env files; they are not read automatically by the process","Match credentials to the configured environment (testnet vs live)","Check has_api_credentials() on the config before attempting connect"],"tags":["credentials","authentication","environment","execution","deribit"],"backgroundTag":"missing-credentials","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}