tonhowtf/omniget · error · anyhow

informe primeiro o client_id da sua app do Trakt

Error message

informe primeiro o client_id da sua app do Trakt (crie em {})

What it means

Thrown by TraktLists::device_code before starting the OAuth device flow when the locally stored Trakt config has an empty client_id. The device-code endpoint requires the application's client_id to identify the registered Trakt app, so without it the flow cannot start. The message points to APP_URL (https://trakt.tv/oauth/applications) where the app is created.

Solutions

  1. Create an app at https://trakt.tv/oauth/applications and copy its client_id
  2. Save the client_id into the tool's Trakt config (the same store read by load() under LOCK) before calling device_code()
  3. Re-run device_code() after the config is populated

Example fix

// before
config.client_secret = "abc123"; // client_id forgotten
save(config);
device_code().await?;
// after
config.client_id = "<trakt app client_id>";
config.client_secret = "abc123";
save(config);
device_code().await?;
Defensive patterns

Strategy: validation

Validate before calling

if config.client_id.trim().is_empty() {
    return Err("configure o client_id do Trakt antes de conectar".into());
}

Type guard

fn has_client_id(c: &TraktConfig) -> bool { !c.client_id.trim().is_empty() }

Prevention

When it happens

Trigger: Calling device_code() before ever saving a Trakt config containing client_id, or after the config file exists but the client_id field was left blank/unwritten.

Common situations: Fresh install where the user connected no app yet; user created a Trakt app but only pasted the client_secret; a config migration/reset wiped the client_id field.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/lists/trakt.rs:235

            Poll::Expired => "o código expirou antes de você liberar",
            Poll::Denied => "acesso negado no site do Trakt",
            Poll::Http(_) => "o Trakt respondeu algo inesperado",
        }
    }
}

fn client() -> Result<reqwest::Client> {
    crate::core::tools::client()
}

/// Passo 1: pede o código que o usuário vai digitar em trakt.tv/activate.
pub async fn device_code() -> Result<DeviceCode> {
    let c = {
        let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());
        load()
    };
    if c.client_id.is_empty() {
        return Err(anyhow!(
            "informe primeiro o client_id da sua app do Trakt (crie em {})",
            APP_URL
        ));
    }
    let r = client()?
        .post(format!("{}/oauth/device/code", AUTH))
        .json(&serde_json::json!({ "client_id": c.client_id }))
        .send()
        .await?;
    if !r.status().is_success() {
        return Err(anyhow!(
            "o Trakt recusou o pedido de código (HTTP {}) — confira o client_id",
            r.status()
        ));
    }
    let v: Value = r.json().await?;
    parse_device_code(&v)
}

View on GitHub (pinned to 8600b91f42)