tonhowtf/omniget · error · anyhow::Error
busca vazia
Error message
busca vazia
What it means
Input validation in the X/Twitter search: search() bails out when the query, after trimming, is an empty string. It fires when a caller invokes the search with a blank query (e.g. an empty or whitespace-only search box value), before any GraphQL timeline request is made.
Solutions
- Validate the query is non-empty before calling search().
- In UI code, disable the search action until input is non-blank.
- If empty search is meant to list trending/default feed, use the appropriate feed API instead of search().
Example fix
// before
let page = search(&user_input, "latest", None).await?;
// after
let q = user_input.trim();
if q.is_empty() {
return Err(anyhow::anyhow!("informe um termo de busca"));
}
let page = search(q, "latest", None).await?; Defensive patterns
Strategy: validation
Validate before calling
if query.trim().is_empty() {
return Err(anyhow::anyhow!("query obrigatoria"));
} Prevention
- Trim and check user input at the boundary (UI/CLI) before calling search().
- Disable search buttons/actions while the input is blank.
- Use the default feed endpoint for 'show me posts' flows instead of an empty search.
When it happens
Trigger: Calling search("", feed, cursor) or search(" ", ...) — a whitespace-only or empty query string passed from the UI or an upstream parser.
Common situations: Front-end sending an empty search box value; a command stripping a flag value; an empty query after normalization/trimming in calling code.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/3849c96e8c131d61.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/x/search.rs:22
//! falhar, no `SearchTimeline` do GraphQL.
use serde::{Deserialize, Serialize};
use serde_json::json;
use super::XPost;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchPage {
pub posts: Vec<XPost>,
pub cursor: Option<String>,
pub source: String,
}
/// `feed`: "latest" | "top".
pub async fn search(query: &str, feed: &str, cursor: Option<&str>) -> anyhow::Result<SearchPage> {
let q = query.trim();
if q.is_empty() {
anyhow::bail!("busca vazia");
}
let feed = if feed == "top" { "top" } else { "latest" };
match super::fx::search(q, feed, cursor).await {
Ok(page) => Ok(SearchPage {
posts: page.items,
cursor: page.cursor,
source: "fxtwitter".into(),
}),
Err(fx_err) => {
let client = super::client::XClient::new()?;
if !client.authed() {
return Err(fx_err);
}
let mut vars = json!({
"rawQuery": q,
"count": 40,
"querySource": "typed_query",
"product": if feed == "top" { "Top" } else { "Latest" },View on GitHub (pinned to 8600b91f42)