jackwener/OpenCLI · error · CommandExecutionError

Title not found: ${id}

Error message

Title not found: ${id}

What it means

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'.

Source

Thrown at clis/imdb/title.js:38

        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 || '')
                .filter(Boolean)
                .join(', ');
        };
        const year = (() => {
            if (isTvSeries && typeof data.startDate === 'string') {
                const startYear = data.startDate.split('-')[0] || '';

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the title ID is correct — search by name with the search command instead of guessing IDs.
  2. Check the title actually exists on imdb.com in a browser.
  3. If the title exists but the error persists, IMDb may have changed its JSON-LD structure; update or report the library issue.

Example fix

// before
await imdbTitle({ id: 'tt0000001' }); // exists but may be a non-standard type
// after
const hits = await imdbSearch({ query: 'Carmencita' });
await imdbTitle({ id: hits[0].id });
Defensive patterns

Strategy: try-catch

Validate before calling

if (!/^tt\d{7,8}$/.test(id)) throw new Error(`invalid IMDb title id: ${id}`);
// verify existence via search first if the ID came from user input

Type guard

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

Try / catch

try {
  return await imdbTitle({ id });
} catch (e) {
  if (new RegExp(`Title not found: ${id}`).test(e.message)) {
    const hits = await imdbSearch({ query: fallbackName });
    if (hits.length) return imdbTitle({ id: hits[0].id });
  }
  throw e;
}

Prevention

When it happens

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

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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