jackwener/OpenCLI · warning · EmptyResultError

No matching spaces on huggingface.co.

Error message

No matching spaces on huggingface.co.

What it means

An EmptyResultError raised when the Hugging Face Spaces API returned valid JSON but the array was empty — no spaces matched the query. The library treats an empty result as an error so CLI callers get a clear 'nothing found' message rather than blank output.

Source

Thrown at clis/hf/spaces.js:82

        if (resp.status === 429) {
            throw new CommandExecutionError(
                'hf spaces returned HTTP 429 (rate limited)',
                'Hugging Face throttles unauthenticated traffic; wait a few seconds and retry.',
            );
        }
        if (!resp.ok) {
            throw new CommandExecutionError(`hf spaces failed: HTTP ${resp.status}`);
        }
        let data;
        try {
            data = await resp.json();
        }
        catch (err) {
            throw new CommandExecutionError(`hf spaces returned malformed JSON: ${err?.message ?? err}`);
        }
        const list = Array.isArray(data) ? data : [];
        if (!list.length) {
            throw new EmptyResultError('hf spaces', 'No matching spaces on huggingface.co.');
        }
        return list.slice(0, limit).map((s, i) => {
            const id = String(s.id ?? s._id ?? '');
            const slash = id.indexOf('/');
            const author = String(s.author ?? (slash > 0 ? id.slice(0, slash) : ''));
            const tags = Array.isArray(s.tags) ? s.tags.filter((t) => !String(t).startsWith('license:')).slice(0, 10).join(', ') : '';
            return {
                rank: i + 1,
                id,
                author,
                sdk: String(s.sdk ?? ''),
                likes: s.likes != null ? Number(s.likes) : null,
                tags,
                lastModified: String(s.lastModified ?? '').slice(0, 10),
                url: id ? `https://huggingface.co/spaces/${id}` : '',
            };
        });
    },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the search term spelling and try a broader query
  2. Verify the space exists at huggingface.co/<author>/<space> and is public
  3. Remove filters (author, tags) and retry with fewer constraints
  4. If the space is private/gated, authenticate with an HF token

Example fix

// before: single strict query
await hfSpaces('my-typoed-space-name');
// after
let res = await hfSpaces('my-typoed-space-name');
if (!res.length) res = await hfSpaces('my-typoed'); // broader fallback search
Defensive patterns

Strategy: validation

Validate before calling

// verify the space exists before querying
const exists = await fetch(`https://huggingface.co/api/spaces/${owner}/${name}`)
  .then(r => r.ok).catch(() => false);
if (!exists) console.warn(`space ${owner}/${name} not found or private`);

Type guard

const hasResults = (res) => Array.isArray(res) && res.length > 0;

Try / catch

try {
  const spaces = await hfSpaces(query);
} catch (e) {
  if (e.name === 'EmptyResultError' || String(e.message).includes('No matching spaces')) {
    return { spaces: [], note: 'no match — try broader query' }; // graceful empty
  }
  throw e;
}

Prevention

When it happens

Trigger: GET /api/spaces?search=... returns [] because no public space matches the search term, author, or filters; also when the API response is not an array (list defaults to []).

Common situations: Typo in the space name/author in the search query; querying a private or deleted space (not visible unauthenticated); overly restrictive filters; HF silently returning a non-array payload.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/8c01ff595474f6a8. Report an issue: GitHub.