jackwener/OpenCLI · error · CommandExecutionError

Discord search result selector returned no rows and no expli

Error message

Discord search result selector returned no rows and no explicit empty-state marker.

What it means

When the search scrape returns zero rows, the command checks searchState.empty (a marker from the page's 'no results' text). If there are no rows AND no empty-state marker, it throws CommandExecutionError — the library cannot tell whether the search genuinely found nothing or the selectors simply failed to match, so it refuses to report an empty result.

Source

Thrown at clis/discord-app/search.js:61

            Author: author,
            Message: (content || '').substring(0, 200),
          });
        });
        
        const bodyText = document.body?.innerText || document.body?.textContent || '';
        const empty = /no results|no messages match|没有结果|无结果/i.test(bodyText);
        return { items, empty };
      })()
    `);
        if (!searchState || !Array.isArray(searchState.items)) {
            throw new CommandExecutionError('Discord search returned malformed browser payload.');
        }
        const results = searchState.items;
        // Close search
        await page.pressKey('Escape');
        if (results.length === 0) {
            if (!searchState.empty) {
                throw new CommandExecutionError('Discord search result selector returned no rows and no explicit empty-state marker.');
            }
            throw new EmptyResultError('discord-app search', `No results for "${query}".`);
        }
        return results;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Increase the wait after typing the query so results/empty-state finish rendering, then retry.
  2. Add your UI language's 'no results' wording to the empty regex in search.js if you run a localized client.
  3. Re-run the search to rule out a mid-load scrape.
  4. Update result-row selectors if Discord changed its markup.

Example fix

// before
const empty = /no results|no messages match|没有结果|无结果/i.test(bodyText);
// after
const empty = /no results|nothing found|no messages match|没有结果|无结果|nessun risultato/i.test(bodyText);
Defensive patterns

Strategy: validation

Validate before calling

// confirm results or an empty-state marker exist before interpreting
await page.waitForSelector('[class*="searchResults"], [class*="search-result"]');

Type guard

function searchStateIsDecidable(s) { return (s.items && s.items.length > 0) || s.empty === true; }

Try / catch

try {
  await run('discord-app search --query=...');
} catch (e) {
  if (/no rows and no explicit empty-state marker/.test(e.message)) {
    // likely localization or slow render: extend empty regex / wait, then retry
    await page.wait(1.5);
    await run('discord-app search --query=...');
  }
}

Prevention

When it happens

Trigger: Discord renders results but the row selector matches none of them (DOM change), the results list is still loading when scraped, the empty-state text doesn't match the /no results|no messages match|没有结果|无结果/i regex (new wording or localized UI in another language), or the search pane rendered in an unexpected container.

Common situations: Discord UI language other than English/Chinese so the empty-state regex misses; results panel animation delaying rows; Discord update changing result row classes.

Related errors


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