zoo kcl lint --show-code panics on multi-line or non-ASCII findings, and zoo kcl lint always exits 0
Context: API Makeathon participant. Found while reviewing the lint command (which runs fully locally, no engine).
1. --show-code panics
src/cmd_kcl.rs:1739-1755:
if self.show_code {
if start.line != end.line {
unimplemented!() // raw panic, exit 101
}
let printable_line = code.lines().collect::<Vec<&str>>()[start.line as usize];
println!("...", &printable_line[..(start.character as usize)], ...); // byte-slice by char offset
Two problems:
- Any finding whose span crosses a line boundary hits
unimplemented!(), a raw Rust panic with a backtrace, instead of an error or a degraded rendering. The lint engine can produce multi-line spans and nothing upstream filters them.
start.character / end.character come from to_lsp_range (character offsets), but they are used to byte-slice printable_line. On a line with any multi-byte character before the finding (Ø, µ, a degree sign in a comment), the slice lands mid-codepoint and panics with "byte index is not a char boundary", or underlines the wrong columns.
2. lint always exits 0
CmdKclLint::run returns Ok(()) regardless of how many findings it printed (src/cmd_kcl.rs:1712-1759), so zoo kcl lint always exits 0 and cannot gate CI on lint findings.
Concrete failure
zoo kcl lint --show-code file.kcl on a file with a non-ASCII comment preceding a same-line finding aborts with a panic (exit 101, "please report this" backtrace), reading as a CLI crash rather than a lint result. And a CI job running zoo kcl lint passes even when findings exist.
Verify
Construct a KCL file where a lint finding sits after a // °C comment on the same line and run with --show-code, or code-review that unimplemented!() is reachable. Run zoo kcl lint on a file with findings and check $? (it is 0).
Suggested fix
Handle multi-line spans without panicking, slice by character (or convert LSP offsets to byte offsets) for the underline, and return a nonzero exit when findings are present (or behind a --deny flag).
Environment
Zoo CLI v0.2.184 (33534cd). Reviewed against the current main of KittyCAD/cli.
zoo kcl lint --show-codepanics on multi-line or non-ASCII findings, andzoo kcl lintalways exits 0Context: API Makeathon participant. Found while reviewing the lint command (which runs fully locally, no engine).
1.
--show-codepanicssrc/cmd_kcl.rs:1739-1755:Two problems:
unimplemented!(), a raw Rust panic with a backtrace, instead of an error or a degraded rendering. The lint engine can produce multi-line spans and nothing upstream filters them.start.character/end.charactercome fromto_lsp_range(character offsets), but they are used to byte-sliceprintable_line. On a line with any multi-byte character before the finding (Ø,µ, a degree sign in a comment), the slice lands mid-codepoint and panics with "byte index is not a char boundary", or underlines the wrong columns.2.
lintalways exits 0CmdKclLint::runreturnsOk(())regardless of how many findings it printed (src/cmd_kcl.rs:1712-1759), sozoo kcl lintalways exits 0 and cannot gate CI on lint findings.Concrete failure
zoo kcl lint --show-code file.kclon a file with a non-ASCII comment preceding a same-line finding aborts with a panic (exit 101, "please report this" backtrace), reading as a CLI crash rather than a lint result. And a CI job runningzoo kcl lintpasses even when findings exist.Verify
Construct a KCL file where a lint finding sits after a
// °Ccomment on the same line and run with--show-code, or code-review thatunimplemented!()is reachable. Runzoo kcl linton a file with findings and check$?(it is 0).Suggested fix
Handle multi-line spans without panicking, slice by character (or convert LSP offsets to byte offsets) for the underline, and return a nonzero exit when findings are present (or behind a
--denyflag).Environment
Zoo CLI v0.2.184 (33534cd). Reviewed against the current
mainof KittyCAD/cli.