{"record":{"id":"b3e878fa89353b40","repo":"jackwener/OpenCLI","slug":"search-keyword-cannot-be-empty","errorCode":null,"errorMessage":"Search keyword cannot be empty","messagePattern":"Search keyword cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"clis/ctrip/hotel-suggest.js","lineNumber":31,"sourceCode":"    site: 'ctrip',\n    name: 'hotel-suggest',\n    access: 'read',\n    description: '搜索携程酒店上下文联想：城市、商圈、单酒店匹配',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'query', required: true, positional: true, help: 'Search keyword (city, business area, or hotel name)' },\n        { name: 'limit', default: 15, help: 'Number of results (1-50)' },\n    ],\n    columns: [\n        'rank', 'id', 'type', 'displayType', 'name', 'eName',\n        'cityId', 'cityName', 'provinceName', 'countryName',\n        'lat', 'lon', 'score', 'url',\n    ],\n    func: async (kwargs) => {\n        const query = String(kwargs.query || '').trim();\n        if (!query) {\n            throw new ArgumentError('Search keyword cannot be empty');\n        }\n        const limit = parseLimit(kwargs.limit);\n        const raw = await fetchSuggest(query, 'H');\n        const rows = raw\n            .filter((item) => !!item && typeof item === 'object')\n            .slice(0, limit)\n            .map(mapSuggestRow)\n            .filter((row) => row.name);\n        if (!rows.length) {\n            throw new EmptyResultError('ctrip hotel-suggest', 'Try a city, business area, or hotel keyword such as \"陆家嘴\" or \"汉庭酒店\"');\n        }\n        return rows;\n    },\n});\n","sourceCodeStart":13,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ctrip/hotel-suggest.js#L13-L46","documentation":"ArgumentError thrown by ctrip hotel-suggest when the query argument is missing, empty, or only whitespace. The command requires a non-empty search keyword to call Ctrip's suggest endpoint; the library normalizes the input with String(...).trim() and rejects anything that trims to ''. This is a client-side input validation error, not a network one.","triggerScenarios":"Calling the hotel-suggest command with no query kwarg, query: '' or query: '   ', or passing a non-string (null/undefined/number) that String()-coerces to empty.","commonSituations":"Forgetting the --query flag in a script; piping an empty variable from shell expansion; passing null from upstream code; typos like --q instead of --query.","solutions":["Pass a non-empty query, e.g. --query \"陆家嘴\"","Trim and check user input before invoking the command","Check the flag/kwargs name is exactly query"],"exampleFix":"// before\nawait ctrip.hotelSuggest({ query: process.argv[3] }); // undefined if flag missing\n// after\nconst q = (process.argv[3] || '').trim();\nif (!q) throw new Error('usage: --query <keyword>');\nawait ctrip.hotelSuggest({ query: q });","handlingStrategy":"validation","validationCode":"const q = String(kwargs.query ?? '').trim();\nif (!q) throw new Error('query is required and cannot be empty');\nawait ctrip.hotelSuggest({ query: q });","typeGuard":"const isValidQuery = (q) => typeof q === 'string' && q.trim().length > 0;","tryCatchPattern":"try {\n  const suggestions = await ctrip.hotelSuggest({ query });\n} catch (e) {\n  if (e instanceof ArgumentError) {\n    console.error('Provide a non-empty --query, e.g. --query \"陆家嘴\"');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Validate/trim user input before calling suggest","Require the --query flag explicitly in wrapper scripts","Guard against empty shell variable expansion (${var:?})","Use exact kwarg name query"],"tags":["validation","arguments","input"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}