{"record":{"id":"0860a589ecc48d3a","repo":"jackwener/OpenCLI","slug":"tvmaze-returned-no-shows-matching-query","errorCode":null,"errorMessage":"TVmaze returned no shows matching \"${query}\".","messagePattern":"TVmaze returned no shows matching \"(.+?)\"\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/tvmaze/search.js","lineNumber":37,"sourceCode":"    browser: false,\n    args: [\n        { name: 'query', positional: true, type: 'string', required: true, help: 'TV show title or fragment to search for' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max rows to return (1-50)' },\n    ],\n    columns: [\n        'rank', 'id', 'name', 'type', 'language', 'genres',\n        'status', 'premiered', 'ended', 'network', 'rating',\n        'matchScore', 'summary', 'url',\n    ],\n    func: async (args) => {\n        const query = requireString(args.query, 'query');\n        const limit = requireBoundedInt(args.limit, 20, 50, 'limit');\n        const list = await tvmazeFetch(\n            `${TVMAZE_BASE}/search/shows?q=${encodeURIComponent(query)}`,\n            `tvmaze search ${query}`,\n        );\n        if (!Array.isArray(list) || list.length === 0) {\n            throw new EmptyResultError('tvmaze search', `TVmaze returned no shows matching \"${query}\".`);\n        }\n        const rows = list.slice(0, limit).map((entry, i) => {\n            const show = entry?.show ?? {};\n            const network = show.network?.name ?? show.webChannel?.name ?? '';\n            return {\n                rank: i + 1,\n                id: typeof show.id === 'number' ? show.id : null,\n                name: String(show.name ?? '').trim(),\n                type: String(show.type ?? '').trim(),\n                language: String(show.language ?? '').trim(),\n                genres: joinList(show.genres),\n                status: String(show.status ?? '').trim(),\n                premiered: typeof show.premiered === 'string' ? show.premiered : null,\n                ended: typeof show.ended === 'string' ? show.ended : null,\n                network: String(network).trim(),\n                rating: show.rating?.average == null ? null : Number(show.rating.average),\n                matchScore: typeof entry?.score === 'number' ? entry.score : null,\n                summary: stripHtml(show.summary),","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tvmaze/search.js#L19-L55","documentation":"This EmptyResultError is thrown when the TVmaze /search/shows API responds successfully but returns an empty array (or a non-array), meaning no shows matched the query string. The adapter treats 'no results' as a distinct, expected outcome rather than a network or parsing failure. It is informational about search specificity, not a malfunction.","triggerScenarios":"Calling the `tvmaze search` command with a query string that matches zero shows in the TVmaze database — typos, very obscure titles, or over-specific queries like 'game of thrones season 2'.","commonSituations":"Misspelled show names; searching by actor or character name instead of show title; searching non-English titles not indexed by TVmaze; passing the full episode title instead of the series name.","solutions":["Shorten and simplify the query to the core show title.","Check spelling of the show name.","Search the title directly on tvmaze.com to confirm it exists in their database.","Handle EmptyResultError in calling code and prompt the user for a different query."],"exampleFix":"// before\nawait tvmazeSearch('game of thrones season 2 episode 1');\n// after\nawait tvmazeSearch('game of thrones');","handlingStrategy":"try-catch","validationCode":"const q = String(query ?? '').trim();\nif (!q) throw new Error('A non-empty show title is required before calling tvmaze search');","typeGuard":"function isNonEmptyString(v) {\n    return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n    const rows = await tvmazeSearch(query);\n} catch (err) {\n    if (err instanceof EmptyResultError) {\n        console.log(`No TVmaze shows found for \"${query}\"; try a shorter title.`);\n    } else {\n        throw err;\n    }\n}","preventionTips":["Trim and simplify queries to the core show title before searching","Check the title exists on tvmaze.com when a search unexpectedly returns nothing","Always handle EmptyResultError separately from network errors","Avoid appending season/episode detail to search queries"],"tags":["empty-results","search","api","tvmaze"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}