{"record":{"id":"d7c667bf25665d3d","repo":"toeverything/AFFiNE","slug":"invalid-delta-range-or-bound-size","errorCode":null,"errorMessage":"Invalid delta range or bound size.","messagePattern":"Invalid delta range or bound size\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"blocksuite/framework/global/src/gfx/bound.ts","lineNumber":138,"sourceCode":"  );\n}\n\nexport function getBoundFromPoints(points: IVec[]) {\n  return Bound.from(getIBoundFromPoints(points));\n}\n\nexport function inflateBound(bound: IBound, delta: number) {\n  const half = delta / 2;\n\n  const newBound = new Bound(\n    bound.x - half,\n    bound.y - half,\n    bound.w + delta,\n    bound.h + delta\n  );\n\n  if (newBound.w <= 0 || newBound.h <= 0) {\n    throw new Error('Invalid delta range or bound size.');\n  }\n\n  return newBound;\n}\n\nexport function transformPointsToNewBound<T extends { x: number; y: number }>(\n  points: T[],\n  oldBound: IBound,\n  oldMargin: number,\n  newBound: IBound,\n  newMargin: number\n) {\n  const wholeOldMargin = oldMargin * 2;\n  const wholeNewMargin = newMargin * 2;\n  const oldW = Math.max(oldBound.w - wholeOldMargin, 1);\n  const oldH = Math.max(oldBound.h - wholeOldMargin, 1);\n  const newW = Math.max(newBound.w - wholeNewMargin, 1);\n  const newH = Math.max(newBound.h - wholeNewMargin, 1);","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/framework/global/src/gfx/bound.ts#L120-L156","documentation":"inflateBound computes the expanded rectangle from a delta and throws when the result has non-positive width or height, i.e. the caller requested an inflation that would collapse or invert the bound — a pure geometry input validation.","triggerScenarios":"Thrown at blocksuite/framework/global/src/gfx/bound.ts:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the delta range (start/end or offset/length) lies within the bound's size before applying it.","Clamp the delta range to the bound's dimensions: range.start >= bound.min and range.end <= bound.max.","Verify the bound itself is valid (w >= 0, h >= 0) before computing delta ranges against it."],"exampleFix":"const clamped = {\n  start: Math.max(0, Math.min(delta.start, bound.maxX)),\n  end: Math.max(0, Math.min(delta.end, bound.maxX)),\n};\nif (clamped.end < clamped.start) throw new Error('Invalid delta range');","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}