{"record":{"id":"783da80523ea145b","repo":"affaan-m/ECC","slug":"consult-requires-a-natural-language-query-for-exa","errorCode":null,"errorMessage":"Consult requires a natural language query, for example: security reviews","messagePattern":"Consult requires a natural language query, for example: security reviews","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/consult.js","lineNumber":397,"sourceCode":"      };\n    })\n    .filter(result => result.score > 0)\n    .sort((left, right) => right.score - left.score || left.profile.id.localeCompare(right.profile.id))\n    .slice(0, Math.min(3, limit))\n    .map(result => ({\n      id: result.profile.id,\n      description: result.profile.description,\n      moduleCount: result.profile.moduleCount,\n      score: result.score,\n      reasons: result.reasons.length > 0 ? result.reasons : ['related install profile'],\n      installCommand: commandFor('profile', result.profile.id, target),\n    }));\n}\n\nfunction buildConsultation(options) {\n  const queryTokens = tokenize(options.query);\n  if (queryTokens.length === 0) {\n    throw new Error('Consult requires a natural language query, for example: security reviews');\n  }\n\n  const matches = rankComponents({\n    queryTokens,\n    target: options.target,\n    limit: options.limit,\n  });\n  const profiles = rankProfiles({\n    queryTokens,\n    target: options.target,\n    limit: options.limit,\n  });\n\n  return {\n    schemaVersion: SCHEMA_VERSION,\n    query: options.query,\n    target: options.target,\n    generatedAt: new Date().toISOString(),","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/consult.js#L379-L415","documentation":"buildConsultation tokenizes options.query and requires at least one meaningful token before ranking components. An empty or whitespace-only query cannot be ranked, so the tool throws with an example of acceptable input. This is a guard against running a consultation with nothing to search for.","triggerScenarios":"Calling buildConsultation(options) (or the CLI) where options.query is empty string, whitespace, or missing — e.g. all argv words were consumed as flag values or the user passed only flags.","commonSituations":"Running `node scripts/consult.js` with no query text; quoting mistakes causing the query to be swallowed by a flag; programmatically passing query: '' after trimming.","solutions":["Pass a natural language query, e.g. `node scripts/consult.js \"security reviews\"`.","Check flag parsing so positional words are not consumed as flag values (queryParts assembly in parseArgs).","In code, validate query non-empty before calling buildConsultation and prompt the user otherwise."],"exampleFix":"// before\nnode scripts/consult.js --target skills\n// after\nnode scripts/consult.js --target skills \"security reviews\"","handlingStrategy":"validation","validationCode":"const query = process.argv.slice(2).filter(a => !a.startsWith('--')).join(' ').trim();\nif (!query) {\n  console.error('Usage: consult <natural language query>');\n  process.exit(1);\n}","typeGuard":"function hasQuery(options) { return typeof options?.query === 'string' && options.query.trim().length > 0; }","tryCatchPattern":"try {\n  buildConsultation(options);\n} catch (e) {\n  if (/natural language query/.test(e.message)) {\n    console.error('A query is required, e.g. consult \"security reviews\"');\n  } else throw e;\n}","preventionTips":["Require a positional query argument in wrapper scripts and error out early with usage text.","Trim and check query before invoking in code.","Show --help when argv contains only flags."],"tags":["cli","empty-input","query"],"backgroundTag":"empty-required-field","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}