deepseek-ai/deepseek-harness · error · Error
Invalid `view_range`. It should be a list of two integers.
Error message
Invalid `view_range`. It should be a list of two integers.
What it means
Shape guard on the optional view_range argument in formatFileView: the array is not exactly two integers (wrong length or non-integer elements). It fires while formatting the view, before any range-boundary checks; the view_range input is at fault.
Solutions
- Pass view_range as [startLine, endLine] with two integers
- Omit view_range to view the whole file
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/fs/tool-str-replace-editor/src/index.ts:155 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/e0d00b4512aa356a.
Report an issue: GitHub.
Appendix: source
Thrown at packages/fs/tool-str-replace-editor/src/index.ts:155
path: string,
content: string,
maxOutputChars: number,
viewRange?: number[],
): string {
const allLines = content.split('\n')
let lines = allLines
let initialLine = 1
let finalLine: number | undefined
let prompt = `Here's the content of ${path} with line numbers (which has a total of ${allLines.length} lines)`
if (viewRange !== undefined) {
const [requestedInitialLine, requestedFinalLine] = viewRange
if (
viewRange.length !== 2
|| requestedInitialLine === undefined
|| requestedFinalLine === undefined
|| !viewRange.every(Number.isInteger)
) {
throw new Error('Invalid `view_range`. It should be a list of two integers.')
}
initialLine = requestedInitialLine
finalLine = requestedFinalLine
if (initialLine < 1 || initialLine > allLines.length) {
throw new Error(
`Invalid \`view_range\`: [${viewRange.join(', ')}]. Its first element \`${initialLine}\` should be within the range of lines of the file: [1, ${allLines.length}]`,
)
}
if (finalLine > allLines.length) {
throw new Error(
`Invalid \`view_range\`: [${viewRange.join(', ')}]. Its second element \`${finalLine}\` should be smaller than the number of lines in the file: \`${allLines.length}\``,
)
}
if (finalLine !== -1 && finalLine < initialLine) {
throw new Error(
`Invalid \`view_range\`: [${viewRange.join(', ')}]. Its second element \`${finalLine}\` should be larger or equal than its first \`${initialLine}\``,
)
}View on GitHub (pinned to b150a551b8)