jackwener/OpenCLI · warning · CommandExecutionError

IMDb redirected to a different title: ${currentId}

Error message

IMDb redirected to a different title: ${currentId}

What it means

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.

Source

Thrown at clis/imdb/title.js:32

    browser: true,
    args: [
        { name: 'id', positional: true, required: true, help: 'IMDb title ID (tt1375666) or URL' },
    ],
    columns: ['field', 'value'],
    func: async (page, args) => {
        const id = normalizeImdbId(String(args.id), 'tt');
        const url = forceEnglishUrl(`https://www.imdb.com/title/${id}/`);
        await page.goto(url);
        const onTitlePage = await waitForImdbPath(page, `^/title/${id}/`);
        if (await isChallengePage(page)) {
            throw new CommandExecutionError('IMDb blocked this request', 'Try again with a normal browser session or extension mode');
        }
        if (!onTitlePage) {
            throw new CommandExecutionError(`Title page did not finish loading: ${id}`, 'Retry the command; if it persists, IMDb may have changed their navigation flow');
        }
        const currentId = await getCurrentImdbId(page, 'tt');
        if (currentId && currentId !== id) {
            throw new CommandExecutionError(`IMDb redirected to a different title: ${currentId}`, 'Retry the command; if it persists, the title page may have changed');
        }
        // Single browser roundtrip: fetch title JSON-LD by type whitelist
        const titleTypes = ['Movie', 'TVSeries', 'TVEpisode', 'TVMiniseries', 'TVMovie', 'TVSpecial', 'VideoGame', 'ShortFilm'];
        const ld = await extractJsonLd(page, titleTypes);
        if (!ld) {
            throw new CommandExecutionError(`Title not found: ${id}`, 'Check the title ID and try again');
        }
        const data = ld;
        const type = String(data['@type'] || '');
        const isTvSeries = type === 'TVSeries' || type === 'TVMiniseries';
        // Handle both array and single-object JSON-LD person fields
        const toPeople = (arr) => {
            if (!arr)
                return '';
            const list = Array.isArray(arr) ? arr : [arr];
            return list
                .slice(0, 5)
                .map((p) => p.name || '')

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the currentId reported in the error message as the correct canonical title ID.
  2. Look up the title afresh via the search command to get its current canonical ID.
  3. Retry if transient; if persistent, update your stored IDs to IMDb's canonical ones.

Example fix

// before
await imdbTitle({ id: 'tt0133093' }); // redirected to different id
// after
try {
  await imdbTitle({ id: 'tt0133093' });
} catch (e) {
  const m = /redirected to a different title: (tt\d+)/.exec(e.message);
  if (m) return imdbTitle({ id: m[1] });
  throw e;
}
Defensive patterns

Strategy: fallback

Validate before calling

if (!/^tt\d{7,8}$/.test(id)) throw new Error(`invalid IMDb title id: ${id}`);

Type guard

function isValidTitleId(id) {
  return typeof id === 'string' && /^tt\d{7,8}$/.test(id);
}

Try / catch

try {
  return await imdbTitle({ id });
} catch (e) {
  const m = /redirected to a different title: (tt\d+)/.exec(e.message);
  if (m) return imdbTitle({ id: m[1] }); // follow IMDb's canonical redirect
  throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: Requesting deprecated/merged title IDs that IMDb canonicalizes to another entry, typos in an ID that coincidentally redirect, or IMDb consolidating duplicate titles.

Related errors


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