tonhowtf/omniget · error

nao consegui ler o perfil da sessao

Error message

nao consegui ler o perfil da sessao

What it means

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.

Solutions

  1. Verify the X session credentials/cookies are valid and not expired; re-authenticate and retry.
  2. Inspect the raw response body for an X error envelope (errors array) and surface it instead of the generic message.
  3. Check whether X changed the GraphQL shape of data.user.result and update parse_user accordingly.
  4. Retry after a delay if the account is rate-limited or temporarily locked.

Example fix

// before
v.pointer("/data/user/result")
    .and_then(super::parse::parse_user)
    .ok_or_else(|| anyhow!("nao consegui ler o perfil da sessao"))
// after
let user = v.pointer("/data/user/result")
    .and_then(super::parse::parse_user)
    .ok_or_else(|| {
        if !v.get("errors").unwrap_or(&Value::Null).is_null() {
            anyhow!("sessao invalida: {}", v["errors"])
        } else {
            anyhow!("nao consegui ler o perfil da sessao")
        }
      })?;
Defensive patterns

Strategy: validation

Validate before calling

// preflight: ensure session credentials exist and the profile resolves
if session_cookies.is_empty() {
    return Err(anyhow!("sessao ausente: faca login antes de usar o tool de follows"));
}

Type guard

fn session_user_ok(v: &Value) -> Option<&Value> {
    v.pointer("/data/user/result").filter(|u| u.get("rest_id").is_some())
}

Try / catch

match tool_follows_me().await {
    Ok(u) => u,
    Err(e) if e.to_string().contains("perfil da sessao") => {
        eprintln!("sessao invalida ou expirada; refaca o login: {e}");
        return; // re-authenticate path
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/8d6f76ce55aa2d7a. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/x/follows.rs:90

    *log.entry(today()).or_default() += 1;
    let _ = std::fs::write(log_path(), serde_json::to_string(&log).unwrap_or_default());
}

pub async fn me(client: &XClient) -> anyhow::Result<XUser> {
    let uid = client
        .user_id()
        .ok_or_else(|| anyhow!("cookie twid ausente: entre de novo no X"))?;
    let v = client
        .gql_get(
            "UserByRestId",
            json!({ "userId": uid, "withSafetyModeUserFields": true }),
            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 }),
            None,
        )
        .await?;
    v.pointer("/data/user/result")
        .and_then(super::parse::parse_user)
        .ok_or_else(|| anyhow!("nao consegui ler o perfil da sessao"))
}

async fn list(
    client: &XClient,
    op: &str,
    uid: &str,
    limit: usize,
    progress: &ProgressFn,
    stage: &str,
) -> anyhow::Result<Vec<XUser>> {
    let mut users: Vec<XUser> = Vec::new();
    let extra = if op == "Followers" {
        json!({ "responsive_web_twitter_article_notes_tab_enabled": false })
    } else {
        json!({})
    };
    let p2 = progress.clone();
    client

View on GitHub (pinned to 8600b91f42)