tonhowtf/omniget · error

cookie twid ausente: entre de novo no X

Error message

cookie twid ausente: entre de novo no X

What it means

follows::me needs the authenticated user's numeric id, taken from the XClient's stored cookies (the `twid` cookie carries u=<id>). If user_id() returns None the client has no twid cookie, so it cannot issue the UserByRestId lookup and reports that the user must log in to X again.

Solutions

  1. Log in to X again so a complete cookie set including twid is captured and stored
  2. Check authed()/user_id() before calling follows::me and route to the login flow instead
  3. Verify the cookie storage file was not truncated (re-import all cookies from the browser session)
  4. Confirm the twid cookie value parses as u=<id>; fix malformed imports

Example fix

// before
let user = follows::me(&client).await?;
// after
if client.user_id().is_none() {
    prompt_relogin()?; // captures twid cookie
}
let user = follows::me(&client).await?;
Defensive patterns

Strategy: validation

Validate before calling

// Rust: guard before calling follows::me
if client.user_id().is_none() {
    return Err(anyhow!("twid cookie missing — log in to X first"));
}

Type guard

// Rust: narrowing helper
fn has_session(client: &XClient) -> bool {
    client.authed() && client.user_id().is_some()
}

Try / catch

match follows::me(&client).await {
    Err(e) if e.to_string().contains("twid ausente") => {
        relogin()?; // capture full cookie set incl. twid
        follows::me(&client).await
    }
    r => r,
}

Prevention

When it happens

Trigger: Calling follows::me (directly or via audit) with an XClient constructed without cookies, with a cookie jar missing the twid entry (guest session or partial login), or after cookies were cleared/corrupted on disk.

Common situations: Fresh install before any X login; login flow captured auth_token/ct0 but not twid; user cleared cookies in the browser and re-imported a partial jar; running in guest mode where twid is never set.

Related errors


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

Appendix: source

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

        .ok()
        .and_then(|s| serde_json::from_str(&s).ok())
        .unwrap_or_default();
    log.get(&today()).copied().unwrap_or(0)
}

fn bump_today() {
    let mut log: std::collections::HashMap<String, usize> = std::fs::read_to_string(log_path())
        .ok()
        .and_then(|s| serde_json::from_str(&s).ok())
        .unwrap_or_default();
    *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,

View on GitHub (pinned to 8600b91f42)