Skip to content

Let a catalog search name a scope without a query - #8

Merged
kev1n merged 1 commit into
mainfrom
search-scope-without-query
Sep 5, 2026
Merged

kev1n merged 1 commit into
mainfrom
search-scope-without-query

Conversation

@kev1n

@kev1n kev1n commented Sep 5, 2026

Copy link
Copy Markdown
Member

What was broken

The gateway's ranked search requires at least one of q, category, platform, in any combination. Measured against production today:

/catalog/search?platform=reddit   -> 200
/catalog/search?category=social   -> 200
/catalog/search                   -> 400 {"error":"name q, category, or platform"}

The node was stricter. searchRequest opened with const qs: IDataObject = { q: query } and the Query field was required: true, so "every reddit API" or "everything in the social category" was expressible over MCP and over curl but impossible from a workflow. Gateway PR getanyapi-com/anyapi#1013 relaxed the MCP side; this node was never updated.

What changed

  • Query is no longer required. Its description now says to leave it empty to list everything a Category or Platform filter scopes to.
  • searchRequest omits q entirely when the query is empty, matching how browseRequest already treats an absent category. It never sends q empty.
  • A search naming none of the three is rejected at the operation boundary with a NodeOperationError, next to the existing Max Items validation, and never reaches the gateway.

discovery.ts keeps owning the wire contract and the node keeps owning n8n-facing errors, so the Seam AGENTS.md describes is preserved.

This does not change what a saved workflow sends

  • A saved workflow with Query filled sends the same q it always sent. Proven by an assertion in the new test.

  • A saved workflow that left Query empty was already sending q= empty, and the gateway reads an empty q as absent. Measured against production:

    /catalog/search?q=&category=social&limit=3  -> 200, first result bluesky.post
    /catalog/search?category=social&limit=3     -> 200, first result bluesky.post
    

    So dropping the empty q returns the identical result set.

  • A saved workflow with neither now gets a clear node error instead of a gateway 400.

No limit, default, or cap was introduced. The tolerant-reader rules are untouched: the reader still rejects credit keys and any provider that is not "AnyAPI", and nothing derives or repairs relationships among returned fields.

Proof

Gate, on this branch:

$ npm run check          # n8n community-node lint, tsc + icons, node --test
ℹ tests 32
ℹ pass 32
ℹ fail 0

$ npm run canary:live
Live discovery canary passed (363 APIs, 1 search result, ahrefs.backlinks).

Both new tests were confirmed red against the pre-fix searchRequest and with the guard removed:

✖ ranked search scopes on a filter alone and omits q rather than sending it empty
  actual: { q: '', platform: 'reddit' }, expected: { platform: 'reddit' }
✖ ranked search naming no query, category, or platform never reaches the gateway
  did not match /Search needs a Query, or a Category or Platform filter to scope it\./

Live against https://api.getanyapi.com, driven through the node's real execute seam with the built dist/:

--- scope-only, Platform filter, empty Query
    URL sent: https://api.getanyapi.com/catalog/search?platform=reddit&limit=5
    total=11 ranking=keyword
    reddit.post              AnyAPI  $1.2/1k req
    reddit.post_comments     AnyAPI  $2/1k req
    reddit.post_transcript   AnyAPI  $2/1k req
    reddit.profile           AnyAPI  $1.2/1k req
    reddit.search            AnyAPI  $1.2/1k req

--- scope-only, Category filter, empty Query
    URL sent: https://api.getanyapi.com/catalog/search?category=social&limit=3
    total=167 ranking=keyword
    bluesky.post             AnyAPI  $2/1k req
    bluesky.profile          AnyAPI  $2/1k req
    bluesky.user_posts       AnyAPI  $2/1k req

--- existing form, Query filled
    URL sent: https://api.getanyapi.com/catalog/search?q=reddit+posts&limit=3
    total=52 ranking=semantic
    reddit.subreddit_posts   AnyAPI  $0.9/1k req
    reddit.user_posts        AnyAPI  $0.9/1k req
    reddit.trending_posts    AnyAPI  $0.36/1k req

--- no query and no filter: rejected locally, 0 requests sent
    Search needs a Query, or a Category or Platform filter to scope it.

Note the two rankings: a scope with no query ranks keyword, a query ranks semantic. Both come from the gateway; the node reports what it is told.

Not in this PR

No version bump, tag, or npm publish. Releasing is a separate decision.

The sibling fix for the CLI is getanyapi-com/cli#17.

🤖 Generated with Claude Code

The gateway's ranked search accepts any non-empty combination of q,
category and platform, so /catalog/search?platform=reddit is a 200. The
node could not express that: searchRequest opened with `{ q: query }` and
the Query field was required, so "every reddit API" was reachable over
MCP and over curl but not from a workflow.

Query is now optional and searchRequest omits q entirely when it is
empty, matching how browseRequest treats an absent category. This does
not change what a saved workflow sends: one with a filled Query still
sends the same q, and one that left Query empty was already sending an
empty q that the gateway reads as absent, so it keeps the results it had.

A search naming none of the three is rejected at the operation boundary
with a NodeOperationError, alongside the existing Max Items validation,
rather than being sent to the gateway to earn a 400. discovery.ts keeps
owning the wire contract and the node keeps owning n8n-facing errors.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kev1n
kev1n merged commit c0e1b25 into main Sep 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant