tonhowtf/omniget · error
agendamento sem token da API
Error message
agendamento sem token da API
What it means
In the Instagram scheduler loop, a post with mode == "graph" (publish via the official Instagram Graph API) must carry its stored Graph API auth/token in post.graph. When that field is None the job cannot be published and fails with 'agendamento sem token da API' ('scheduling without API token').
Solutions
- Reconnect the Instagram account via the Graph API OAuth flow so a token is stored, then re-save the post.
- Change the post's mode from "graph" to web (app-API) publishing if Graph API credentials are unavailable.
- Check that token storage isn't clearing post.graph on refresh/expiry — persist a refreshed token instead of nulling the field.
- Add validation when creating/updating posts: reject mode="graph" without graph auth so the bad row never reaches the scheduler.
- Inspect the post row (post.id in job 'schedule:<id>') to confirm graph is null before re-authenticating.
Example fix
// before
// post saved with mode="graph" and no token, fails at schedule time
api.addPost({ mode: "graph", request });
// after
const auth = await getGraphAuth(accountSlug);
if (!auth) throw new Error("connect Instagram via Graph API before scheduling");
api.addPost({ mode: "graph", graph: auth, request }); Defensive patterns
Strategy: validation
Validate before calling
function assertGraphPost(post) {
if (post.mode === 'graph' && !post.graph) {
throw new Error(`post ${post.id}: mode=graph requires a Graph API token; reconnect the account`);
}
}
assertGraphPost(post); // call before saving/scheduling Type guard
function hasGraphAuth(post) {
return post.mode !== 'graph' || (post.graph != null && typeof post.graph === 'object');
} Prevention
- Require OAuth completion before allowing mode=graph on a post
- Refresh and persist Graph tokens instead of nulling them on expiry
- Validate post rows at creation/edit time, not only at schedule time
- Surface scheduler failures per job id so users know which post needs re-auth
When it happens
Trigger: A scheduled Instagram post row was created with mode="graph" but post.graph is null — the account was never connected via the Graph API flow, the token was cleared/expired and removed, or the post was edited to graph mode without supplying credentials.
Common situations: User switched scheduling mode to Graph API without completing the Facebook/Instagram OAuth connection; token revoked in the Meta developer console; database row created by an older version that did not persist graph auth; token expiration cleanup job nulling post.graph.
Related errors
- Graph API
- o container falhou
- a API oficial so aceita URLs publicas (https://…) para os…
- download falhou: HTTP
- GROK_NO_KEY
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/f164cb8ac18b7554.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/src/commands/tools/instagram.rs:788
pub fn start_scheduler(app: tauri::AppHandle) {
if SCHEDULER.set(()).is_err() {
return;
}
tauri::async_runtime::spawn(async move {
loop {
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
let now = chrono::Utc::now().timestamp();
let Some(mut post) = publish::schedule_due(now) else {
continue;
};
post.status = "running".into();
let _ = publish::schedule_update(&post);
let job = format!("schedule:{}", post.id);
let p = progress(&app);
let outcome = if post.mode == "graph" {
match &post.graph {
Some(auth) => publish::publish_graph(auth, &post.request, &p, &job).await,
None => Err(anyhow::anyhow!("agendamento sem token da API")),
}
} else {
match load_client(post.account_slug.as_deref()) {
Ok(client) => publish::publish_web(&client, &post.request, &p, &job).await,
Err(e) => Err(anyhow::anyhow!(e)),
}
};
match outcome {
Ok(r) => {
post.status = "done".into();
post.result = Some(r);
}
Err(e) => {
post.status = "failed".into();
post.error = Some(e.to_string());
}
}
let _ = publish::schedule_update(&post);View on GitHub (pinned to 8600b91f42)