{"record":{"id":"200c14ed5fa67e61","repo":"jackwener/OpenCLI","slug":"not-found-200c14","errorCode":"NOT_FOUND","errorMessage":"No stock found for \"${key}\"","messagePattern":"No stock found for \"(.+?)\"","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"warning","filePath":"clis/sinafinance/stock.js","lineNumber":81,"sourceCode":"        { name: 'market', type: 'string', default: 'auto', help: 'Market: cn, hk, us, auto (default: auto searches cn → hk → us)' },\n    ],\n    columns: ['Symbol', 'Name', 'Price', 'Change', 'ChangePercent', 'Open', 'High', 'Low', 'Volume', 'MarketCap'],\n    func: async (args) => {\n        const key = String(args.key);\n        const market = String(args.market);\n        const marketMap = {\n            cn: [MARKET_CN], hk: [MARKET_HK], us: [MARKET_US],\n            auto: [MARKET_CN, MARKET_HK, MARKET_US],\n        };\n        const targetMarkets = marketMap[market];\n        if (!targetMarkets) {\n            throw new CliError('INPUT_ERROR', `Invalid market: \"${market}\"`, 'Expected cn, hk, us, or auto');\n        }\n        // 1. Search symbol — only request the markets we care about\n        const suggestRaw = await fetchGBK(`https://suggest3.sinajs.cn/suggest/type=${targetMarkets.join(',')}&key=${encodeURIComponent(key)}`);\n        const entries = parseSuggest(suggestRaw, targetMarkets);\n        if (!entries.length) {\n            throw new CliError('NOT_FOUND', `No stock found for \"${key}\"`, 'Try a different name, code, or --market');\n        }\n        // Pick best match: score by name/symbol similarity, tiebreak by market priority\n        const needle = key.toLowerCase();\n        const score = (e) => {\n            const n = e.name.toLowerCase();\n            const s = e.symbol.toLowerCase();\n            if (s === needle || n === needle)\n                return 1;\n            if (s.includes(needle))\n                return needle.length / s.length;\n            if (n.includes(needle))\n                return needle.length / n.length;\n            return 0;\n        };\n        const best = entries.sort((a, b) => {\n            const d = score(b) - score(a);\n            return d !== 0 ? d : targetMarkets.indexOf(a.market) - targetMarkets.indexOf(b.market);\n        })[0];","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/sinafinance/stock.js#L63-L99","documentation":"This CliError with code NOT_FOUND is thrown after calling the sina suggest API when no stock entries match the user's search key in the requested markets. parseSuggest returned an empty array, meaning the suggest3.sinajs.cn endpoint returned no usable suggestions for the given key and target market list. It indicates a search-key/market mismatch rather than a network or parse failure.","triggerScenarios":"Running the stock lookup CLI with a key that matches no symbol or company name on sina's suggest endpoint (typo, delisted stock, unsupported name), or restricting markets via --market to one where the stock is not listed so the filtered entries array is empty.","commonSituations":"Typing a pinyin/partial name the suggest API does not recognize; searching a US/HK ticker while --market is left as cn; searching an A-share code while forcing --market us; delisted or renamed securities; using a non-standard code format like '600000.SH' instead of the bare code.","solutions":["Re-run with a more accurate ticker code or full company name","Remove the --market restriction or set it to 'auto' so all supported markets (cn, hk, us) are searched","Try alternative spellings of the name (English vs Chinese vs pinyin) or the bare 6-digit code for CN stocks","Verify the security still trades (not delisted/suspended) via another data source"],"exampleFix":"// before\nstock 'PDD' --market cn   // no match in cn market\n// after\nstock 'PDD' --market us   # or omit --market to search all markets","handlingStrategy":"validation","validationCode":"function looksLikeTickerOrCode(key) {\n  return typeof key === 'string' && /^[A-Za-z0-9.一-龥]{2,20}$/.test(key.trim());\n}\nif (!looksLikeTickerOrCode(key)) throw new Error('Provide a valid stock code or name');","typeGuard":"const isSuggestEntry = (e) => typeof e?.symbol === 'string' && typeof e?.name === 'string' && typeof e?.market === 'string';","tryCatchPattern":"try {\n  await stock(key, { market });\n} catch (e) {\n  if (e.code === 'NOT_FOUND') console.error(`No match for \"${key}\" — check spelling or try --market auto`);\n  else throw e;\n}","preventionTips":["Prefer exact ticker codes over fuzzy name searches","Leave --market as auto unless you are certain of the listing venue","Handle e.code === 'NOT_FOUND' distinctly from network errors in CLI wrappers"],"tags":["cli","http","search","not-found"],"backgroundTag":"no-search-results","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}