deepseek-ai/deepseek-harness · error · Error

The `view_range` parameter is not allowed when `path`…

Error message

The `view_range` parameter is not allowed when `path` points to a directory.

What it means

Parameter-combination guard in viewPath: the target resolved to a directory, where line-range filtering is meaningless, so view_range is rejected even though the view command itself accepts directories.

Solutions

  1. Omit view_range when viewing a directory
  2. Point path at a file if a line-range view is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/fs/tool-str-replace-editor/src/index.ts:227 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/669ba88096feba5f. Report an issue: GitHub.

Appendix: source

Thrown at packages/fs/tool-str-replace-editor/src/index.ts:227

    const rightPath = right.slice(right.indexOf('\t') + 1)
    return codepointCompare(leftPath, rightPath)
  })
  const listing = maybeTruncate(rows.join('\n') + '\n', maxOutputChars)
  return `Here're the files and directories up to 2 levels deep in ${target.displayPath}, excluding hidden items, node_modules, and Python cache directories:\n${listing}\n`
}

async function viewPath(
  ctx: Context,
  path: string,
  viewRange: number[] | undefined,
  maxOutputChars: number,
  exec: ToolRunContext,
): Promise<string> {
  const target = await resolveTarget(ctx, path, exec.signal)
  const info = await statExisting(ctx, target, 'view', exec)
  if (info.type === 'directory') {
    if (viewRange !== undefined) {
      throw new Error('The `view_range` parameter is not allowed when `path` points to a directory.')
    }
    return listDirectory(ctx, target, maxOutputChars, exec)
  }
  if (info.type !== 'file') {
    throw new FsError(`cannot view "${target.displayPath}": not a regular file or directory`, 'FS_NOT_REGULAR_FILE')
  }
  const content = await ctx.fs.readText(target, exec.signal)
  ctx.emit('fs/observed', target, { kind: 'present', version: info.version }, exec)
  return formatFileView(target.displayPath, content, maxOutputChars, viewRange)
}

async function createFile(
  ctx: Context,
  policy: MutationPolicy,
  path: string,
  fileText: string | undefined,
  exec: ToolRunContext,
): Promise<string> {

View on GitHub (pinned to b150a551b8)