jackwener/OpenCLI · error · CommandExecutionError

Maimai search API payload missing talent list

Error message

Maimai search API payload missing talent list

What it means

CommandExecutionError thrown when the payload is a valid object but none of the known list fields (data.data.list, data.data.talent_list, data.list, data.talent_list) is an array. The CLI treats a missing list field as API shape drift rather than an empty result, to avoid silently reporting zero candidates.

Source

Thrown at clis/maimai/search-talents.js:141

      return result;
    }`);

    if (!data || typeof data !== 'object' || Array.isArray(data)) {
      throw new CommandExecutionError('Maimai search returned malformed API payload');
    }

    // Extract talent list from response. Missing list fields mean the API
    // shape drifted; only an explicit empty array is a true empty result.
    const talentListCandidates = [
      data.data?.list,
      data.data?.talent_list,
      data.list,
      data.talent_list,
    ];
    const talentList = talentListCandidates.find((value) => Array.isArray(value));
    if (!talentList) {
      throw new CommandExecutionError('Maimai search API payload missing talent list');
    }

    if (talentList.length === 0) {
      throw new EmptyResultError('maimai search-talents', `未找到匹配 "${query}" 的候选人`);
    }

    // Map to output format
    return talentList.map(item => {
      // Extract school info (first one)
      const schoolInfo = item.edu && item.edu.length > 0 ? item.edu[0] : {};

      // Work years: use work_time field directly (e.g., "11 年", "10 年")
      const workYear = item.work_time || item.worktime || '';

      // Extract all companies from work experience (deduplicated, excluding current company)
      const currentCompany = item.company || '';
      const historicalCompanies = (item.exp || [])
        .map(e => e.company)

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the payload keys (console.log(Object.keys(data))) and add the new path to talentListCandidates.
  2. Update the CLI to the latest version expecting the new schema.
  3. Verify with a manual browser request that the endpoint still returns a list field.
  4. If maimai really changed contracts, file/patch the CLI's candidate array.

Example fix

// before
const talentListCandidates = [
  data.data?.list,
  data.data?.talent_list,
  data.list,
  data.talent_list,
];
// after
const talentListCandidates = [
  data.data?.list,
  data.data?.talent_list,
  data.data?.result?.list,
  data.list,
  data.talent_list,
  data.result,
];
Defensive patterns

Strategy: validation

Validate before calling

const list = [data.data?.list, data.data?.talent_list, data.list, data.talent_list].find(Array.isArray);
if (!list) console.error('unexpected maimai payload keys:', Object.keys(data ?? {}));

Type guard

function hasTalentList(d) { return [d?.data?.list, d?.data?.talent_list, d?.list, d?.talent_list].some(Array.isArray); }

Try / catch

try {
  const talents = await searchTalents(query);
} catch (e) {
  if (/missing talent list/.test(e.message)) {
    console.error('maimai schema drifted; update CLI or inspect payload keys');
  } else throw e;
}

Prevention

When it happens

Trigger: Maimai returns a success object whose talent list lives under a renamed/new field, or the object contains only meta/status fields.

Common situations: Maimai API version change renaming the list key, account/permission differences returning an error object with code 200, paginated responses moving results elsewhere.

Related errors


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