{"record":{"id":"27b36fdcc3716ff7","repo":"jackwener/OpenCLI","slug":"maimai-search-api-payload-missing-talent-list","errorCode":null,"errorMessage":"Maimai search API payload missing talent list","messagePattern":"Maimai search API payload missing talent list","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/maimai/search-talents.js","lineNumber":141,"sourceCode":"\n      return result;\n    }`);\n\n    if (!data || typeof data !== 'object' || Array.isArray(data)) {\n      throw new CommandExecutionError('Maimai search returned malformed API payload');\n    }\n\n    // Extract talent list from response. Missing list fields mean the API\n    // shape drifted; only an explicit empty array is a true empty result.\n    const talentListCandidates = [\n      data.data?.list,\n      data.data?.talent_list,\n      data.list,\n      data.talent_list,\n    ];\n    const talentList = talentListCandidates.find((value) => Array.isArray(value));\n    if (!talentList) {\n      throw new CommandExecutionError('Maimai search API payload missing talent list');\n    }\n\n    if (talentList.length === 0) {\n      throw new EmptyResultError('maimai search-talents', `未找到匹配 \"${query}\" 的候选人`);\n    }\n\n    // Map to output format\n    return talentList.map(item => {\n      // Extract school info (first one)\n      const schoolInfo = item.edu && item.edu.length > 0 ? item.edu[0] : {};\n\n      // Work years: use work_time field directly (e.g., \"11 年\", \"10 年\")\n      const workYear = item.work_time || item.worktime || '';\n\n      // Extract all companies from work experience (deduplicated, excluding current company)\n      const currentCompany = item.company || '';\n      const historicalCompanies = (item.exp || [])\n        .map(e => e.company)","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maimai/search-talents.js#L123-L159","documentation":"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.","triggerScenarios":"Maimai returns a success object whose talent list lives under a renamed/new field, or the object contains only meta/status fields.","commonSituations":"Maimai API version change renaming the list key, account/permission differences returning an error object with code 200, paginated responses moving results elsewhere.","solutions":["Inspect the payload keys (console.log(Object.keys(data))) and add the new path to talentListCandidates.","Update the CLI to the latest version expecting the new schema.","Verify with a manual browser request that the endpoint still returns a list field.","If maimai really changed contracts, file/patch the CLI's candidate array."],"exampleFix":"// before\nconst talentListCandidates = [\n  data.data?.list,\n  data.data?.talent_list,\n  data.list,\n  data.talent_list,\n];\n// after\nconst talentListCandidates = [\n  data.data?.list,\n  data.data?.talent_list,\n  data.data?.result?.list,\n  data.list,\n  data.talent_list,\n  data.result,\n];","handlingStrategy":"validation","validationCode":"const list = [data.data?.list, data.data?.talent_list, data.list, data.talent_list].find(Array.isArray);\nif (!list) console.error('unexpected maimai payload keys:', Object.keys(data ?? {}));","typeGuard":"function hasTalentList(d) { return [d?.data?.list, d?.data?.talent_list, d?.list, d?.talent_list].some(Array.isArray); }","tryCatchPattern":"try {\n  const talents = await searchTalents(query);\n} catch (e) {\n  if (/missing talent list/.test(e.message)) {\n    console.error('maimai schema drifted; update CLI or inspect payload keys');\n  } else throw e;\n}","preventionTips":["Keep the CLI updated for maimai schema changes.","Dump Object.keys(payload) on failure to spot renamed fields quickly.","Pin a known-good CLI version in CI and test after maimai releases."],"tags":["api","schema-drift","payload"],"backgroundTag":"api-schema-drift","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}