astral-sh/ruff · error · Error
Invalid value `0` for `position.line`. The line index is 1-i
Error message
Invalid value `0` for `position.line`. The line index is 1-indexed.
What it means
A wasm-bindgen Error from Position::to_text_size: the caller passed 0 for position.line. The wasm API mirrors 1-based editor coordinates (via OneIndexed), so line 0 is out of range and cannot be converted to an offset.
Source
Thrown at crates/ty_wasm/src/lib.rs:1183
#[wasm_bindgen]
impl Position {
#[wasm_bindgen(constructor)]
pub fn new(line: usize, column: usize) -> Self {
Self { line, column }
}
}
impl Position {
fn to_text_size(
self,
text: &str,
index: &LineIndex,
position_encoding: PositionEncoding,
) -> Result<TextSize, Error> {
let text_size = index.offset(
SourceLocation {
line: OneIndexed::new(self.line).ok_or_else(|| {
Error::new(
"Invalid value `0` for `position.line`. The line index is 1-indexed.",
)
})?,
character_offset: OneIndexed::new(self.column).ok_or_else(|| {
Error::new(
"Invalid value `0` for `position.column`. The column index is 1-indexed.",
)
})?,
},
text,
position_encoding.into(),
);
Ok(text_size)
}
fn from_text_size(
offset: TextSize,View on GitHub (pinned to 26f38c119c)
Solutions
- Pass a 1-indexed line number (first line is 1)
- Convert 0-based editor coordinates to 1-based before calling the API
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ty_wasm/src/lib.rs:1183 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05).
Data as JSON: /api/errors/f4cfe2eaf37acb3c.
Report an issue: GitHub.