{"record":{"id":"438091181701cf77","repo":"nautechsystems/nautilus_trader","slug":"incomplete-lighter-credentials-set-api-key-var","errorCode":null,"errorMessage":"incomplete Lighter credentials: set {api_key_var}, {api_secret_var}, and {account_index_var}","messagePattern":"incomplete Lighter credentials: set (.+?), (.+?), and (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/common/credential.rs","lineNumber":277,"sourceCode":"    out\n}\n\nfn credential_from_resolved_values(\n    api_key_index: Option<u8>,\n    account_index: Option<u64>,\n    api_secret: Option<String>,\n    api_key_var: &str,\n    api_secret_var: &str,\n    account_index_var: &str,\n) -> anyhow::Result<Option<Credential>> {\n    match (api_key_index, account_index, api_secret) {\n        (Some(api_key_index), Some(account_index), Some(api_secret)) => Ok(Some(Credential::new(\n            api_key_index,\n            api_secret,\n            account_index,\n        )?)),\n        (None, None, None) => Ok(None),\n        _ => anyhow::bail!(\n            \"incomplete Lighter credentials: set {api_key_var}, {api_secret_var}, and {account_index_var}\"\n        ),\n    }\n}\n\nfn resolve_api_key_index(value: Option<u8>, env_var: &str) -> anyhow::Result<Option<u8>> {\n    match value {\n        Some(value) => ensure_api_key_index(value).map(Some),\n        None => get_or_env_var_opt(None::<String>, env_var)\n            .filter(|s| !s.trim().is_empty())\n            .map(|s| parse_api_key_index(&s, env_var))\n            .transpose(),\n    }\n}\n\nfn resolve_account_index(value: Option<u64>, env_var: &str) -> anyhow::Result<Option<u64>> {\n    match value {\n        Some(value) => Ok(Some(value)),","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/common/credential.rs#L259-L295","documentation":"Lighter credentials are resolved from three sources (api key index, api secret, account index). Resolution succeeds only when all three are present or all three are absent; a partial set (some set, some missing) is ambiguous and rejected, with the message naming the exact env vars that must be set.","triggerScenarios":"Calling credential_from_resolved_values (via resolve_for_deployment) when exactly one or two of api_key_index/account_index/api_secret are provided — e.g. LIGHTER_API_KEY_INDEX and LIGHTER_API_SECRET set but LIGHTER_ACCOUNT_INDEX missing.","commonSituations":"Partial environment configuration during setup or migration; rotating credentials and clearing only one variable; provisioning systems injecting only part of the credential set; forgetting the account index, which is unique to Lighter.","solutions":["Set all three env vars: the api key index var, api secret var, and account index var named in the error message (e.g. LIGHTER_API_KEY_INDEX, LIGHTER_API_SECRET, LIGHTER_ACCOUNT_INDEX).","Alternatively unset all three if unauthenticated/no-credential operation is intended.","Audit your deployment environment/dotenv file so the credential set is complete and consistent.","Add a startup validation step that checks the three vars together before launching the adapter."],"exampleFix":"// before\nexport LIGHTER_API_KEY_INDEX=1\nexport LIGHTER_API_SECRET=...\n# LIGHTER_ACCOUNT_INDEX missing\n// after\nexport LIGHTER_API_KEY_INDEX=1\nexport LIGHTER_API_SECRET=...\nexport LIGHTER_ACCOUNT_INDEX=12345","handlingStrategy":"validation","validationCode":"let key_idx = env::var(\"LIGHTER_API_KEY_INDEX\").ok();\nlet secret = env::var(\"LIGHTER_API_SECRET\").ok();\nlet acct = env::var(\"LIGHTER_ACCOUNT_INDEX\").ok();\nlet set = [key_idx.is_some(), secret.is_some(), acct.is_some()];\nif set.iter().any(|&x| x) && !set.iter().all(|&x| x) {\n    return Err(\"incomplete Lighter credentials: set all three vars or none\".into());\n}","typeGuard":null,"tryCatchPattern":"match resolve_for_deployment() {\n    Err(e) if e.to_string().contains(\"incomplete Lighter credentials\") => {\n        // fail startup with a clear operator message naming the missing vars\n    }\n    r => r?,\n}","preventionTips":["Provision all three Lighter env vars (api key index, api secret, account index) as one unit.","Validate credential completeness at adapter startup, before trading.","When rotating credentials, replace the whole set atomically.","Use a checked dotenv/environment template that lists all three required vars."],"tags":["lighter","credentials","configuration","environment"],"backgroundTag":"missing-env-var","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}