xurl X backend fails on topics containing 'and'/'or' (raw topic sent to X API v2 search)

Author: clairernovotnyCreated Sep 28, 2026Updated Sep 28, 2026

Summary

With the xurl X backend, any topic that contains a bare and or or fails the whole X lane. The report only says xurl: search failed. search_x() in scripts/lib/xurl_x.py sends the raw topic straight to xurl search. The official X API v2 search grammar rejects a bare lowercase and/or as an ambiguous keyword and returns HTTP 400 Invalid Request.

The pipeline always builds the X query from the raw topic (x_query = raw_topic or topic or subquery.search_query in pipeline.py). So this happens even when the host passes a good --plan.

Steps to Reproduce

  1. Configure the xurl backend (app-only bearer; doctor reports will use: xurl).
  2. Run python3 skills/last30days/scripts/last30days.py "AI code review and security review tools for Claude Code and Codex" --search x --quick.
  3. The X lane fails: All X backends failed — xurl: xurl: search failed.

Wrapping xurl shows the real response (identifiers trimmed):

{"detail":"One or more parameters to your request was invalid.",
 "errors":[{"message":"There were errors processing your request: Ambiguous use of and as a keyword. Use a space to logically join two clauses, or \"and\" to find occurrences of and in text (at position 16), ..."}],
 "title":"Invalid Request","type":"https://api.x.com/2/problems/invalid-request"}

The same search without the word "and" ("Claude Code Codex AI code review tools") returns posts.

Expected Behavior

The xurl backend sanitizes the topic the way x_api.build_query() already does. That means dropping bare AND/OR (in any case), colon operators, leading - negation, and grouping or quote characters, while keeping its keyword search. When X does reject a query, the error should say so (for example xurl: X rejected the query (invalid request)) instead of the generic search failed, without echoing CLI output that may contain the bearer.

Error / Traceback

[DEBUG] xurl exit 1: xurl: search failed (665 chars)
[xurl] Error in response: xurl: search failed
[X] backend 'xurl' failed (xurl: search failed); trying next
X: 0 items (error: All X backends failed — xurl: xurl: search failed (run doctor for fixes))

Install Method

Claude Code plugin (also installed as a Codex plugin)

OS

macOS (Darwin 27.2), xurl 1.3.1, last30days 3.25.0


I'll open a PR with the fix and tests.

Source: mvanhorn/last30days-skill