{"record":{"id":"b75a1356ae6ba7b6","repo":"slidevjs/slidev","slug":"invalid-aspect-ratio-str","errorCode":null,"errorMessage":"Invalid aspect ratio \"${str}\"","messagePattern":"Invalid aspect ratio \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/parser/src/utils.ts","lineNumber":46,"sourceCode":"  }\n\n  return uniq(indexes).filter(i => i <= total).sort((a, b) => a - b)\n}\n\n/**\n * Accepts `16/9` `1:1` `3x4`\n */\nexport function parseAspectRatio(str: string | number) {\n  if (isNumber(str))\n    return str\n  if (!Number.isNaN(+str))\n    return +str\n  const [wStr = '', hStr = ''] = str.split(RE_ASPECT_RATIO_SEPARATOR)\n  const w = Number.parseFloat(wStr.trim())\n  const h = Number.parseFloat(hStr.trim())\n\n  if (Number.isNaN(w) || Number.isNaN(h) || h === 0)\n    throw new Error(`Invalid aspect ratio \"${str}\"`)\n\n  return w / h\n}\n","sourceCodeStart":28,"sourceCodeEnd":50,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/parser/src/utils.ts#L28-L50","documentation":"parseAspectRatio accepts a number, a numeric string, or a '<w><sep><h>' string where sep is one of the aspect-ratio separators. After splitting, both sides must be finite numbers and the height must be non-zero.","triggerScenarios":"Setting aspectRatio to a non-numeric string, an incomplete pair ('16/'), a zero height ('16/0'), or using an unsupported separator like underscore.","commonSituations":"Typos, unsupported separators, dividing by zero, pasting values like '16_9'.","solutions":["Use one of the documented forms: 16/9, 1:1, 3x4, or a plain number like 1.7778","Ensure both sides are numeric and the second is non-zero","Use a recognized separator (/ : or x)"],"exampleFix":"// before\naspectRatio: 16_9\n// after\naspectRatio: 16/9","handlingStrategy":"validation","validationCode":"function validAspectRatio(v: string | number): boolean {\n  if (typeof v === 'number' || !Number.isNaN(+v)) return +v > 0\n  const [w = '', h = ''] = String(v).split(/[\\/:x]/)\n  const wn = Number.parseFloat(w.trim()), hn = Number.parseFloat(h.trim())\n  return Number.isFinite(wn) && Number.isFinite(hn) && hn !== 0\n}","typeGuard":"function isAspectRatioInput(v: unknown): v is string | number {\n  return typeof v === 'number' || (typeof v === 'string' && /^\\s*[\\d.]+\\s*[\\/:x]\\s*[\\d.]+\\s*$/.test(v))\n}","tryCatchPattern":null,"preventionTips":["Use 16/9 / 1:1 / 3x4 or a plain number for aspectRatio","Reject zero or empty height in any custom config validator"],"tags":["config","aspect-ratio","validation"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}