{"record":{"id":"b0ff698a97f70d0e","repo":"moghtech/komodo","slug":"failed-to-log-in-msg","errorCode":null,"errorMessage":"Failed to log in | {msg}","messagePattern":"Failed to log in \\| (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"client/core/rs/src/ws/mod.rs","lineNumber":73,"sourceCode":"      .await\n      .with_context(|| {\n        format!(\"failed to connect to Komodo websocket at {endpoint}\")\n      })?;\n    ws.send(tungstenite::Message::Text(login_msg.into()))\n      .await\n      .context(\"Failed to send websocket login message\")?;\n    loop {\n      match ws\n        .try_next()\n        .await\n        .context(\"Failed to receive websocket login response\")?\n      {\n        Some(tungstenite::Message::Text(msg)) => {\n          if msg == \"LOGGED_IN\" {\n            return Ok(ws);\n          } else {\n            let _ = ws.close(None).await;\n            return Err(anyhow!(\"Failed to log in | {msg}\"));\n          }\n        }\n        Some(tungstenite::Message::Close(_)) | None => {\n          let _ = ws.close(None).await;\n          return Err(anyhow!(\"Socket closed before login\"));\n        }\n        // Keep looping on other message types\n        Some(_) => {}\n      };\n    }\n  }\n}\n","sourceCodeStart":55,"sourceCodeEnd":86,"githubUrl":"https://github.com/moghtech/komodo/blob/780ac68b992094a9fccd5fffb760e0c84fd3c3d1/client/core/rs/src/ws/mod.rs#L55-L86","documentation":"connect_login_user_websocket performs a login handshake over the Komodo user websocket, expecting the server to reply with the exact text 'LOGGED_IN'. If any other text message arrives, the client closes the socket and returns this error containing the server's message — i.e. authentication over the websocket was rejected.","triggerScenarios":"Wrong or expired API key/JSON Web Key passed to connect_terminal or subscribe_to_updates; server rejecting credentials and sending a rejection message instead of 'LOGGED_IN'.","commonSituations":"Rotated or revoked Komodo API keys, misconfigured KOMODO_ADDRESS pointing at the wrong server, clock skew invalidating signed auth, or permission changes on the key.","solutions":["Read the {msg} part of the error — it contains the server's rejection reason","Regenerate/verify the API key or JWT key used for authentication","Confirm the target address points at the correct Komodo server with the right account","Check server-side logs for the auth rejection to confirm the credential problem"],"exampleFix":"// before\nlet ws = komodo.connect_terminal(...).await?;\n// after\nlet ws = komodo.connect_terminal(...).await.map_err(|e| {\n    if e.to_string().contains(\"Failed to log in\") {\n        e.context(\"check KOMODO_API_KEY / jwt key and server address\")\n    } else { e }\n})?;","handlingStrategy":"try-catch","validationCode":"if api_key.is_empty() || jwt_key.is_empty() {\n    return Err(anyhow!(\"Komodo credentials missing before opening websocket\"));\n}","typeGuard":null,"tryCatchPattern":"match komodo.connect_terminal(terminal_target).await {\n    Ok(ws) => ws,\n    Err(e) if e.to_string().starts_with(\"Failed to log in\") => {\n        eprintln!(\"auth rejected: {e}\"); // refresh keys and retry\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Rotate and verify API keys before long-running sessions","Validate the Komodo address env var points at the intended server","Monitor server auth-rejection logs"],"tags":["websocket","auth","komodo"],"backgroundTag":"authentication-required","analyzedSha":"780ac68b992094a9fccd5fffb760e0c84fd3c3d1","analyzedAt":"2026-09-08T10:02:44.861Z","contentChangedAt":"2026-09-08T10:02:44.861Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}