{"record":{"id":"98ea972ff66a071f","repo":"jackwener/OpenCLI","slug":"title-not-found-id","errorCode":null,"errorMessage":"Title not found: ${id}","messagePattern":"Title not found: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/imdb/title.js","lineNumber":38,"sourceCode":"        const id = normalizeImdbId(String(args.id), 'tt');\n        const url = forceEnglishUrl(`https://www.imdb.com/title/${id}/`);\n        await page.goto(url);\n        const onTitlePage = await waitForImdbPath(page, `^/title/${id}/`);\n        if (await isChallengePage(page)) {\n            throw new CommandExecutionError('IMDb blocked this request', 'Try again with a normal browser session or extension mode');\n        }\n        if (!onTitlePage) {\n            throw new CommandExecutionError(`Title page did not finish loading: ${id}`, 'Retry the command; if it persists, IMDb may have changed their navigation flow');\n        }\n        const currentId = await getCurrentImdbId(page, 'tt');\n        if (currentId && currentId !== id) {\n            throw new CommandExecutionError(`IMDb redirected to a different title: ${currentId}`, 'Retry the command; if it persists, the title page may have changed');\n        }\n        // Single browser roundtrip: fetch title JSON-LD by type whitelist\n        const titleTypes = ['Movie', 'TVSeries', 'TVEpisode', 'TVMiniseries', 'TVMovie', 'TVSpecial', 'VideoGame', 'ShortFilm'];\n        const ld = await extractJsonLd(page, titleTypes);\n        if (!ld) {\n            throw new CommandExecutionError(`Title not found: ${id}`, 'Check the title ID and try again');\n        }\n        const data = ld;\n        const type = String(data['@type'] || '');\n        const isTvSeries = type === 'TVSeries' || type === 'TVMiniseries';\n        // Handle both array and single-object JSON-LD person fields\n        const toPeople = (arr) => {\n            if (!arr)\n                return '';\n            const list = Array.isArray(arr) ? arr : [arr];\n            return list\n                .slice(0, 5)\n                .map((p) => p.name || '')\n                .filter(Boolean)\n                .join(', ');\n        };\n        const year = (() => {\n            if (isTvSeries && typeof data.startDate === 'string') {\n                const startYear = data.startDate.split('-')[0] || '';","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/imdb/title.js#L20-L56","documentation":"The imdb title command throws this CommandExecutionError when extractJsonLd(page, titleTypes) returns null, i.e. no JSON-LD block of an accepted @type (Movie, TVSeries, TVEpisode, TVMiniseries, TVMovie, TVSpecial, VideoGame, ShortFilm) was found on the loaded title page. The library treats a title page without whitelisted JSON-LD as 'title not found'.","triggerScenarios":"The title page loaded and no redirect happened, but extractJsonLd finds no script[type=application/ld+json] matching the titleTypes whitelist — the requested ID has no valid title page data.","commonSituations":"Passing a well-formed but nonexistent tt ID, requesting a non-whitelisted type (e.g. a person nm page or a podcast series) that has no accepted JSON-LD, or IMDb redesigning/removing its JSON-LD output.","solutions":["Verify the title ID is correct — search by name with the search command instead of guessing IDs.","Check the title actually exists on imdb.com in a browser.","If the title exists but the error persists, IMDb may have changed its JSON-LD structure; update or report the library issue."],"exampleFix":"// before\nawait imdbTitle({ id: 'tt0000001' }); // exists but may be a non-standard type\n// after\nconst hits = await imdbSearch({ query: 'Carmencita' });\nawait imdbTitle({ id: hits[0].id });","handlingStrategy":"try-catch","validationCode":"if (!/^tt\\d{7,8}$/.test(id)) throw new Error(`invalid IMDb title id: ${id}`);\n// verify existence via search first if the ID came from user input","typeGuard":"function isValidTitleId(id) {\n  return typeof id === 'string' && /^tt\\d{7,8}$/.test(id);\n}","tryCatchPattern":"try {\n  return await imdbTitle({ id });\n} catch (e) {\n  if (new RegExp(`Title not found: ${id}`).test(e.message)) {\n    const hits = await imdbSearch({ query: fallbackName });\n    if (hits.length) return imdbTitle({ id: hits[0].id });\n  }\n  throw e;\n}","preventionTips":["Validate ID format and resolve unknown IDs via the search command first.","Only pass IDs obtained from IMDb itself (search results, links) rather than hand-typed values.","Note the whitelist: person (nm) and non-standard pages will not return title data.","If valid titles start failing en masse, suspect an IMDb JSON-LD structure change and update the library."],"tags":["scraping","json-ld","not-found","data-extraction"],"backgroundTag":"resource-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}