moeru-ai/airi · error · Error
Search query is empty. Please provide a query to search.
Error message
Search query is empty. Please provide a query to search.
What it means
Thrown by handleSearchTweets when the parsed command's content is falsy — i.e. 'search tweets:' was sent with no query string. This is a plain Error raised before any browser/API call; no search is executed.
Source
Thrown at integrations/twitter-services/src/adapters/airi-adapter.ts:158
}
}
private async handleSearchTweets(content: string): Promise<boolean> {
if (content) {
const tweets = await this.twitterServices.tweet.searchTweets(content)
logger.main.log(`Found ${tweets.length} tweets for query: ${content}`)
// Return results to the user
this.client.send({
type: 'input:text',
data: {
text: `Found ${tweets.length} tweets for '${content}':
${tweets.slice(0, 5).map((t: Tweet) => `- ${t.text.substring(0, 100)}...`).join('\n')}`,
},
})
return true
}
else {
throw new Error('Search query is empty. Please provide a query to search.')
}
}
private async handleLikeTweet(content: string): Promise<void> {
if (content) {
await this.twitterServices.tweet.likeTweet(content)
logger.main.log(`Liked tweet: ${content}`)
}
else {
throw new Error('Tweet ID is empty. Please provide a tweet ID to like.')
}
}
private async handleRetweet(content: string): Promise<void> {
if (content) {
await this.twitterServices.tweet.retweet(content)
logger.main.log(`Retweeted: ${content}`)
}View on GitHub (pinned to 27111382b4)
Solutions
- Provide a non-empty query after 'search tweets:'.
- Validate content in the parser and reject/reprompt before reaching the handler.
- Have the adapter reply with usage guidance instead of throwing on empty content.
Example fix
// before
if (content) { /* search */ } else {
throw new Error('Search query is empty. Please provide a query to search.')
}
// after
const q = content?.trim()
if (!q) {
this.client.send({ type: 'input:text', data: { text: 'Usage: search tweets: <query>' } })
return false
} Defensive patterns
Strategy: validation
Validate before calling
const q = (content ?? '').trim()
if (!q) {
throw new Error('Search query required')
}
await adapter.handleSearchTweets(q) Type guard
function isEmptySearchQueryError(e: unknown): boolean {
return e instanceof Error && /Search query is empty/.test(e.message)
} Try / catch
try {
await this.handleSearchTweets(content)
} catch (e) {
if (e instanceof Error && /Search query is empty/.test(e.message)) {
this.client.send({ type: 'input:text', data: { text: 'Usage: search tweets: <query>' } })
} else throw e
} Prevention
- Validate the parsed query length in the parser and reprompt.
- Reply with usage guidance instead of throwing on empty input.
- Send only complete 'search tweets: <query>' strings.
When it happens
Trigger: User sends 'search tweets:' or 'search tweets: ' (whitespace-only); parseTwitterCommand matched the 'search tweets' prefix but content trimmed to empty.
Common situations: Premature submit; parser dropped the query payload; LLM emitted only the command keyword; empty input forwarded by the AIRI input:text event.
Related errors
- Tweet text is empty. Please provide text to post.
- Tweet ID is empty. Please provide a tweet ID to like.
- Tweet ID is empty. Please provide a tweet ID to retweet.
- Username is empty. Please provide a username to retrieve.
- Unknown X command: ${input}. Supported commands: "post tweet
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/78d908b896e8d542.
Report an issue: GitHub.