{"record":{"id":"532b6c2252e573d5","repo":"jackwener/OpenCLI","slug":"imdb-redirected-to-a-different-title-currentid-532b6c","errorCode":null,"errorMessage":"IMDb redirected to a different title: ${currentId}","messagePattern":"IMDb redirected to a different title: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"warning","filePath":"clis/imdb/title.js","lineNumber":32,"sourceCode":"    browser: true,\n    args: [\n        { name: 'id', positional: true, required: true, help: 'IMDb title ID (tt1375666) or URL' },\n    ],\n    columns: ['field', 'value'],\n    func: async (page, args) => {\n        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 || '')","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/imdb/title.js#L14-L50","documentation":"The imdb title command throws this CommandExecutionError when getCurrentImdbId(page, 'tt') returns an ID different from the requested one, meaning IMDb redirected the browser to another title's page. The library refuses to return data for the wrong title, since results would be silently incorrect.","triggerScenarios":"After the title page loads (onTitlePage true), getCurrentImdbId reads a current tt ID that differs from args.id — IMDb redirected /title/<id>/ to a different title (merged, canonicalized, or alternate-version redirect).","commonSituations":"Requesting deprecated/merged title IDs that IMDb canonicalizes to another entry, typos in an ID that coincidentally redirect, or IMDb consolidating duplicate titles.","solutions":["Use the currentId reported in the error message as the correct canonical title ID.","Look up the title afresh via the search command to get its current canonical ID.","Retry if transient; if persistent, update your stored IDs to IMDb's canonical ones."],"exampleFix":"// before\nawait imdbTitle({ id: 'tt0133093' }); // redirected to different id\n// after\ntry {\n  await imdbTitle({ id: 'tt0133093' });\n} catch (e) {\n  const m = /redirected to a different title: (tt\\d+)/.exec(e.message);\n  if (m) return imdbTitle({ id: m[1] });\n  throw e;\n}","handlingStrategy":"fallback","validationCode":"if (!/^tt\\d{7,8}$/.test(id)) throw new Error(`invalid IMDb title id: ${id}`);","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  const m = /redirected to a different title: (tt\\d+)/.exec(e.message);\n  if (m) return imdbTitle({ id: m[1] }); // follow IMDb's canonical redirect\n  throw e;\n}","preventionTips":["Periodically refresh stored title IDs against IMDb's canonical entries.","Resolve IDs via search by title name rather than hardcoding legacy IDs.","Parse the redirected ID out of the error and follow it programmatically.","Log redirect events to identify stale IDs in your dataset."],"tags":["redirect","scraping","data-integrity"],"backgroundTag":"unexpected-redirect","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}