{"record":{"id":"c0448bfb201656e7","repo":"jackwener/OpenCLI","slug":"discord-search-result-selector-returned-no-rows-an","errorCode":null,"errorMessage":"Discord search result selector returned no rows and no explicit empty-state marker.","messagePattern":"Discord search result selector returned no rows and no explicit empty-state marker\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/discord-app/search.js","lineNumber":61,"sourceCode":"            Author: author,\n            Message: (content || '').substring(0, 200),\n          });\n        });\n        \n        const bodyText = document.body?.innerText || document.body?.textContent || '';\n        const empty = /no results|no messages match|没有结果|无结果/i.test(bodyText);\n        return { items, empty };\n      })()\n    `);\n        if (!searchState || !Array.isArray(searchState.items)) {\n            throw new CommandExecutionError('Discord search returned malformed browser payload.');\n        }\n        const results = searchState.items;\n        // Close search\n        await page.pressKey('Escape');\n        if (results.length === 0) {\n            if (!searchState.empty) {\n                throw new CommandExecutionError('Discord search result selector returned no rows and no explicit empty-state marker.');\n            }\n            throw new EmptyResultError('discord-app search', `No results for \"${query}\".`);\n        }\n        return results;\n    },\n});\n","sourceCodeStart":43,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/search.js#L43-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"Discord UI language other than English/Chinese so the empty-state regex misses; results panel animation delaying rows; Discord update changing result row classes.","solutions":["Increase the wait after typing the query so results/empty-state finish rendering, then retry.","Add your UI language's 'no results' wording to the empty regex in search.js if you run a localized client.","Re-run the search to rule out a mid-load scrape.","Update result-row selectors if Discord changed its markup."],"exampleFix":"// before\nconst empty = /no results|no messages match|没有结果|无结果/i.test(bodyText);\n// after\nconst empty = /no results|nothing found|no messages match|没有结果|无结果|nessun risultato/i.test(bodyText);","handlingStrategy":"validation","validationCode":"// confirm results or an empty-state marker exist before interpreting\nawait page.waitForSelector('[class*=\"searchResults\"], [class*=\"search-result\"]');","typeGuard":"function searchStateIsDecidable(s) { return (s.items && s.items.length > 0) || s.empty === true; }","tryCatchPattern":"try {\n  await run('discord-app search --query=...');\n} catch (e) {\n  if (/no rows and no explicit empty-state marker/.test(e.message)) {\n    // likely localization or slow render: extend empty regex / wait, then retry\n    await page.wait(1.5);\n    await run('discord-app search --query=...');\n  }\n}","preventionTips":["Keep the Discord client in a language covered by the empty-state regex (English/Chinese) or extend it.","Wait long enough for the results panel to finish animating in.","Treat this error as a selector drift signal — re-verify row selectors after updates.","Test search with a known-good query regularly."],"tags":["discord","selector","scraping","localization"],"backgroundTag":"selector-mismatch","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}