{"record":{"id":"ee62122302a9bda5","repo":"jackwener/OpenCLI","slug":"invalid-argument-ee6212","errorCode":"INVALID_ARGUMENT","errorMessage":"`Unknown sector type \"${typeKey}\". Valid: ${Object.keys(SECTOR_TYPES).join(', ')}`","messagePattern":"`Unknown sector type \"(.+?)\"\\. Valid: (.+?)`","errorType":"validation","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/eastmoney/sectors.js","lineNumber":40,"sourceCode":"\ncli({\n  site: 'eastmoney',\n  name: 'sectors',\n    access: 'read',\n  description: '板块排行（行业/概念/地域）按涨跌幅、主力资金或成交额排序',\n  domain: 'push2.eastmoney.com',\n  strategy: Strategy.PUBLIC,\n  browser: false,\n  args: [\n    { name: 'type', type: 'string', default: 'industry', help: '板块类型：industry / concept / region' },\n    { name: 'sort', type: 'string', default: 'change',   help: '排序：change / drop / money-flow / out-flow / turnover' },\n    { name: 'limit', type: 'int',   default: 20,         help: '返回数量 (max 100)' },\n  ],\n  columns: ['rank', 'code', 'name', 'price', 'changePercent', 'mainNet', 'leadStock', 'leadChangePercent', 'upCount', 'downCount'],\n  func: async (args) => {\n    const typeKey = String(args.type ?? 'industry').toLowerCase();\n    const fs = SECTOR_TYPES[typeKey];\n    if (!fs) throw new CliError('INVALID_ARGUMENT', `Unknown sector type \"${typeKey}\". Valid: ${Object.keys(SECTOR_TYPES).join(', ')}`);\n    const sortKey = String(args.sort ?? 'change').toLowerCase();\n    const sort = SORTS[sortKey];\n    if (!sort) throw new CliError('INVALID_ARGUMENT', `Unknown sort \"${sortKey}\". Valid: ${Object.keys(SORTS).join(', ')}`);\n    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' } });","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/eastmoney/sectors.js#L22-L58","documentation":"The eastmoney sectors CLI validates the --type argument against the SECTOR_TYPES lookup table before building the API query. If the lowercased type key is not found, it throws INVALID_ARGUMENT listing the valid keys. This is a client-side input validation error; no network request is made.","triggerScenarios":"Running the sectors command with --type set to a value not in SECTOR_TYPES, e.g. --type sector or --type ind instead of a valid key like industry or concept.","commonSituations":"Typo in the type flag, translating/abbreviating type names, scripts passing a free-form category name from another tool, case-sensitive assumptions (though the CLI lowercases input).","solutions":["Use one of the valid types listed in the error message (e.g. industry, concept)","Run the command with the default (omit --type) to get industry sectors","Check the CLI help output for the supported type values","Fix the calling script to pass a whitelisted type key"],"exampleFix":"// before\nsectors({ type: 'ind' });\n// after\nsectors({ type: 'industry' });","handlingStrategy":"validation","validationCode":"const SECTOR_TYPES = ['industry','concept'];\nconst type = String(args.type ?? 'industry').toLowerCase();\nif (!SECTOR_TYPES.includes(type)) throw new Error(`type must be one of: ${SECTOR_TYPES.join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  await sectors({ type });\n} catch (e) {\n  if (e.code === 'INVALID_ARGUMENT') console.error('Bad --type:', e.message);\n  else throw e;\n}","preventionTips":["Copy type values from the CLI help instead of guessing","Whitelist sector types in wrapper scripts","Rely on the default (omit --type) when unsure"],"tags":["validation","argument","cli","eastmoney"],"backgroundTag":"invalid-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}