{"record":{"id":"d8937447a930f1f1","repo":"jackwener/OpenCLI","slug":"no-data-d89374","errorCode":"NO_DATA","errorMessage":"eastmoney returned no sector data","messagePattern":"eastmoney returned no sector data","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/eastmoney/sectors.js","lineNumber":62,"sourceCode":"    const limit = Math.max(1, Math.min(Number(args.limit) || 20, 100));\n\n    const url = new URL('https://push2.eastmoney.com/api/qt/clist/get');\n    url.searchParams.set('pn', '1');\n    url.searchParams.set('pz', String(limit));\n    url.searchParams.set('po', sort.order === 'desc' ? '1' : '0');\n    url.searchParams.set('np', '1');\n    url.searchParams.set('fltt', '2');\n    url.searchParams.set('invt', '2');\n    url.searchParams.set('fid', sort.fid);\n    url.searchParams.set('fs', fs);\n    url.searchParams.set('fields', 'f12,f14,f2,f3,f62,f104,f105,f128,f136,f140,f141');\n    url.searchParams.set('ut', 'b2884a393a59ad64002292a3e90d46a5');\n\n    const resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });\n    if (!resp.ok) throw new CliError('HTTP_ERROR', `sectors failed: HTTP ${resp.status}`);\n    const data = await resp.json();\n    const diff = Array.isArray(data?.data?.diff) ? data.data.diff : [];\n    if (diff.length === 0) throw new CliError('NO_DATA', 'eastmoney returned no sector data');\n\n    return diff.slice(0, limit).map((it, i) => ({\n      rank: i + 1,\n      code: it.f12,\n      name: it.f14,\n      price: it.f2,\n      changePercent: it.f3,\n      mainNet: it.f62,\n      leadStock: it.f128,\n      leadChangePercent: it.f136,\n      upCount: it.f104,\n      downCount: it.f105,\n    }));\n  },\n});\n","sourceCodeStart":44,"sourceCodeEnd":78,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/eastmoney/sectors.js#L44-L78","documentation":"After a successful sectors API response, the CLI requires data.data.diff to be a non-empty array. An empty or missing diff means eastmoney returned no sector data for the requested type/sort, so CliError NO_DATA is thrown.","triggerScenarios":"Requesting a sector type/fs whose result list is empty (e.g. an unsupported or deprecated fs value), eastmoney returning data:null for the query, or a schema change moving the diff field.","commonSituations":"eastmoney silently returning empty payloads for some fs values, invalid --type combinations that pass local validation but match nothing server-side, API contract drift after an eastmoney update.","solutions":["Verify the --type value is a supported sector type and try the default","Try a different sort key to see if other queries return data","Call the endpoint directly with curl and the same fs/fid params to inspect the raw payload","Update the CLI if the eastmoney response schema changed"],"exampleFix":"// before\nsectors({ type: 'concept', sort: 'main' }); // returns empty for this combo\n// after\nsectors({ type: 'industry', sort: 'change' });","handlingStrategy":"try-catch","validationCode":"const KNOWN_TYPES = ['industry','concept'];\nif (args.type && !KNOWN_TYPES.includes(String(args.type).toLowerCase())) throw new Error('unsupported sector type');","typeGuard":"function hasSectorData(data) { return Array.isArray(data?.data?.diff) && data.data.diff.length > 0; }","tryCatchPattern":"try {\n  const rows = await sectors({ type, sort });\n} catch (e) {\n  if (e.code === 'NO_DATA') console.warn('eastmoney returned no sector data; try a different type/sort');\n  else throw e;\n}","preventionTips":["Stick to supported type/sort combinations verified against the live API","Log the exact query params when empty results occur for diagnosis","Detect schema drift by checking data.data presence before diff","Keep the CLI updated when eastmoney changes field names"],"tags":["api","empty-result","eastmoney","data"],"backgroundTag":"empty-api-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}