{"record":{"id":"358a38aac4b4d993","repo":"deepseek-ai/deepseek-harness","slug":"invalid-insert-line-parameter-insertline-it","errorCode":null,"errorMessage":"Invalid `insert_line` parameter: ${insertLine}. It should be within the range of lines of the file: [0, ${lines.length}]","messagePattern":"Invalid `insert_line` parameter: (.+?)\\. It should be within the range of lines of the file: \\[0, (.+?)\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fs/tool-str-replace-editor/src/index.ts","lineNumber":345,"sourceCode":"  policy: MutationPolicy,\n  path: string,\n  insertLine: number | undefined,\n  newStr: string | undefined,\n  exec: ToolRunContext,\n): Promise<string> {\n  if (insertLine === undefined) throw new Error('Parameter `insert_line` is required for command: insert')\n  const value = requiredForCommand(newStr, 'new_str', 'insert')\n  const sandboxPolicy = policy.resolve(exec)\n  const target = await resolveTarget(ctx, path, exec.signal)\n  const intent = await ctx.waterfall('fs/edit-intent', target, exec, () => undefined)\n  const info = await statExisting(ctx, target, 'insert', exec)\n  if (info.type !== 'file') {\n    throw new FsError(`cannot insert into \"${target.displayPath}\": not a regular file`, 'FS_NOT_REGULAR_FILE')\n  }\n  const before = await ctx.fs.readText(target, exec.signal)\n  const lines = before.split('\\n')\n  if (!Number.isInteger(insertLine) || insertLine < 0 || insertLine > lines.length) {\n    throw new Error(\n      `Invalid \\`insert_line\\` parameter: ${insertLine}. It should be within the range of lines of the file: [0, ${lines.length}]`,\n    )\n  }\n  const after = [\n    ...lines.slice(0, insertLine),\n    ...value.split('\\n'),\n    ...lines.slice(insertLine),\n  ].join('\\n')\n  const expected: FsWriteIntent = intent === undefined\n    ? { kind: 'replaceIfVersion', version: info.version }\n    : { kind: 'replaceIfVersion', version: intent.version }\n  let outcome\n  try {\n    outcome = await ctx.fs.writeText(target, after, expected, exec.signal, sandboxPolicy)\n  } catch (error: unknown) {\n    throw policy.mapError(error, sandboxPolicy)\n  }\n  ctx.emit('fs/observed', target, { kind: 'present', version: outcome.version }, exec)","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/fs/tool-str-replace-editor/src/index.ts#L327-L363","documentation":"Error \"Invalid `insert_line` parameter: ${insertLine}. It should be within the range of lines of the file: [0, ${lines.length}]\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/fs/tool-str-replace-editor/src/index.ts:345 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}