{"record":{"id":"ad1024af3075ec16","repo":"jackwener/OpenCLI","slug":"command-parser-returned-row-index-1-withou","errorCode":null,"errorMessage":"${command} parser returned row ${index + 1} without required ${field}","messagePattern":"(.+?) parser returned row (.+?) without required (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/hltv/utils.js","lineNumber":862,"sourceCode":"    if (/timeout/i.test(String(error?.message ?? error))) {\n      throw new TimeoutError(label, 15);\n    }\n    throw new CommandExecutionError(`${label} failed: ${error?.message ?? error}`);\n  }\n}\n\nexport function assertRows(rows, command) {\n  if (!Array.isArray(rows)) throw new CommandExecutionError(`${command} parser returned an unexpected shape`);\n  if (rows.length === 0) throw new EmptyResultError(command, 'No rows were found in the visible HLTV page');\n  return rows;\n}\n\nexport function assertRequiredFields(rows, command, fields) {\n  assertRows(rows, command);\n  for (const [index, row] of rows.entries()) {\n    for (const field of fields) {\n      if (row?.[field] === null || row?.[field] === undefined || row?.[field] === '') {\n        throw new CommandExecutionError(`${command} parser returned row ${index + 1} without required ${field}`);\n      }\n    }\n  }\n  return rows;\n}\n","sourceCodeStart":844,"sourceCodeEnd":868,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hltv/utils.js#L844-L868","documentation":"assertRequiredFields walks every parsed row and throws CommandExecutionError('<command> parser returned row N without required <field>') when a row is missing a required field or it is null/undefined/''. It catches partial or malformed extraction after an HLTV markup change.","triggerScenarios":"A parser extracts rows but one or more rows lack a required key (e.g. row without 'team' or 'rating'), typically when HLTV renders optional cells or ad slots where data was expected.","commonSituations":"HLTV inserts promo/sponsored rows or changes column order; a single odd row (e.g. removed team) lacks a stat cell; new HLTV layout shifts field positions.","solutions":["Inspect which row/field is missing and update the parser mapping for that cell","Skip or normalize rows that legitimately lack optional data before validation","Upgrade the CLI if a newer release handles the current HLTV markup","Make the field optional in the fields list if it is not truly required"],"exampleFix":"// before\nassertRequiredFields(rows, 'matches', ['date','team1','team2','score']);\n// after\nconst cleaned = rows.filter(r => r.score != null && r.score !== '');\nassertRequiredFields(cleaned, 'matches', ['date','team1','team2','score']);","handlingStrategy":"validation","validationCode":"const required = ['date','team1','team2'];\nconst bad = rows.findIndex(r => required.some(f => r?.[f] == null || r?.[f] === ''));\nif (bad !== -1) console.warn(`row ${bad + 1} missing required fields; filtering out`);\nconst clean = rows.filter(r => required.every(f => r?.[f] != null && r?.[f] !== ''));","typeGuard":"function hasRequiredFields(row, fields) {\n  return !!row && typeof row === 'object' &&\n    fields.every(f => row[f] !== null && row[f] !== undefined && row[f] !== '');\n}","tryCatchPattern":"try {\n  assertRequiredFields(rows, command, fields);\n} catch (err) {\n  if (err.name === 'CommandExecutionError' && /without required/.test(err.message)) {\n    console.warn(`${command}: dropping malformed rows — ${err.message}`);\n    return rows.filter(r => fields.every(f => r?.[f] != null && r?.[f] !== ''));\n  }\n  throw err;\n}","preventionTips":["Filter out incomplete rows before strict validation","Map HLTV cells defensively with nullish coalescing defaults","Add tests with fixture HTML containing promo/odd rows","Update parser mappings promptly after HLTV markup changes"],"tags":["parsing","schema-mismatch","scraping"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}