{"record":{"id":"8d6f76ce55aa2d7a","repo":"tonhowtf/omniget","slug":"nao-consegui-ler-o-perfil-da-sessao","errorCode":null,"errorMessage":"nao consegui ler o perfil da sessao","messagePattern":"nao consegui ler o perfil da sessao","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/x/follows.rs","lineNumber":90,"sourceCode":"    *log.entry(today()).or_default() += 1;\n    let _ = std::fs::write(log_path(), serde_json::to_string(&log).unwrap_or_default());\n}\n\npub async fn me(client: &XClient) -> anyhow::Result<XUser> {\n    let uid = client\n        .user_id()\n        .ok_or_else(|| anyhow!(\"cookie twid ausente: entre de novo no X\"))?;\n    let v = client\n        .gql_get(\n            \"UserByRestId\",\n            json!({ \"userId\": uid, \"withSafetyModeUserFields\": true }),\n            json!({ \"hidden_profile_likes_enabled\": true, \"subscriptions_verification_info_is_identity_verified_enabled\": false, \"responsive_web_twitter_article_notes_tab_enabled\": false, \"subscriptions_feature_can_gift_premium\": false, \"profile_label_improvements_pcf_label_in_post_enabled\": false }),\n            None,\n        )\n        .await?;\n    v.pointer(\"/data/user/result\")\n        .and_then(super::parse::parse_user)\n        .ok_or_else(|| anyhow!(\"nao consegui ler o perfil da sessao\"))\n}\n\nasync fn list(\n    client: &XClient,\n    op: &str,\n    uid: &str,\n    limit: usize,\n    progress: &ProgressFn,\n    stage: &str,\n) -> anyhow::Result<Vec<XUser>> {\n    let mut users: Vec<XUser> = Vec::new();\n    let extra = if op == \"Followers\" {\n        json!({ \"responsive_web_twitter_article_notes_tab_enabled\": false })\n    } else {\n        json!({})\n    };\n    let p2 = progress.clone();\n    client","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/x/follows.rs#L72-L108","documentation":"This error is thrown in follows.rs after fetching the session user's profile from the X API: the call succeeds at the HTTP level, but the JSON pointer /data/user/result either is absent or fails super::parse::parse_user. It means the session's authenticated-user payload did not contain a parseable user object, so the tool cannot proceed with session-scoped follow operations.","triggerScenarios":"Calling the follows tool's session-profile path when the X GraphQL response lacks data.user.result (e.g. guest/unauthenticated session cookie, X returning an error JSON envelope with HTTP 200, or a schema change to the user result node) so parse_user returns None.","commonSituations":"Expired or invalid X session credentials where X still returns 200 with an error body; rate-limited or logged-out responses; X changing the GraphQL user result shape (e.g. result renamed or wrapped in live_interaction variant); transient account locks.","solutions":["Verify the X session credentials/cookies are valid and not expired; re-authenticate and retry.","Inspect the raw response body for an X error envelope (errors array) and surface it instead of the generic message.","Check whether X changed the GraphQL shape of data.user.result and update parse_user accordingly.","Retry after a delay if the account is rate-limited or temporarily locked."],"exampleFix":"// before\nv.pointer(\"/data/user/result\")\n    .and_then(super::parse::parse_user)\n    .ok_or_else(|| anyhow!(\"nao consegui ler o perfil da sessao\"))\n// after\nlet user = v.pointer(\"/data/user/result\")\n    .and_then(super::parse::parse_user)\n    .ok_or_else(|| {\n        if !v.get(\"errors\").unwrap_or(&Value::Null).is_null() {\n            anyhow!(\"sessao invalida: {}\", v[\"errors\"])\n        } else {\n            anyhow!(\"nao consegui ler o perfil da sessao\")\n        }\n      })?;","handlingStrategy":"validation","validationCode":"// preflight: ensure session credentials exist and the profile resolves\nif session_cookies.is_empty() {\n    return Err(anyhow!(\"sessao ausente: faca login antes de usar o tool de follows\"));\n}","typeGuard":"fn session_user_ok(v: &Value) -> Option<&Value> {\n    v.pointer(\"/data/user/result\").filter(|u| u.get(\"rest_id\").is_some())\n}","tryCatchPattern":"match tool_follows_me().await {\n    Ok(u) => u,\n    Err(e) if e.to_string().contains(\"perfil da sessao\") => {\n        eprintln!(\"sessao invalida ou expirada; refaca o login: {e}\");\n        return; // re-authenticate path\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Refresh session cookies proactively before long audit runs","Check the X response for an errors array before parsing","Log the raw body when /data/user/result is missing to spot schema drift early","Add a smoke test that fetches the session profile before batch operations"],"tags":["x-api","session","authentication","parse"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}