mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 17:56:50 -06:00
CLI: a malformed JSON Lines entry names its step as well as its line (#3147)
Review follow-up (CodeRabbit): a line that wasn't valid JSON was reported by its line only, while every other --commands error names the run's step. It now says `step N (line L)`, N counted with the --cmd steps before it. run_refuses_malformed_commands_naming_the_step expects `step 2 (line 3)`; it fails without the change.
This commit is contained in:
committed by
bflatastic
parent
87fdd4a370
commit
49d69d48e5
@@ -386,7 +386,7 @@ fn parse_commands(source: &str, text: &str, first: usize) -> Result<Vec<Step>, S
|
||||
if entries.len() == MAX_COMMANDS_STEPS {
|
||||
return Err(too_many());
|
||||
}
|
||||
let v = serde_json::from_str(line).map_err(|e| format!("--commands {source}: line {}: {e}", n + 1))?;
|
||||
let v = serde_json::from_str(line).map_err(|e| format!("--commands {source}: step {} (line {}): {e}", first + entries.len(), n + 1))?;
|
||||
entries.push((Some(n + 1), v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ fn run_refuses_malformed_commands_naming_the_step() {
|
||||
bad("params-array.json", br#"[{"command":"select.all","params":[1]}]"#, &["`params` of select.all must be a JSON object"]);
|
||||
bad("typo.json", br#"[{"command":"select.all","param":{}}]"#, &["unknown key `param`"]);
|
||||
bad("broken.json", b"[{\"command\":", &["--commands", "broken.json"]);
|
||||
bad("lines.jsonl", b"{\"command\":\"select.all\"}\n\n{oops}\n", &["line 3"]);
|
||||
bad("lines.jsonl", b"{\"command\":\"select.all\"}\n\n{oops}\n", &["step 2 (line 3)"]);
|
||||
bad("line-array.jsonl", b"{\"command\":\"select.all\"}\n[1]\n", &["step 2 (line 2)"]);
|
||||
bad("latin1.json", b"[{\"command\":\"select.all\",\"params\":{\"name\":\"\xe9\"}}]", &["not UTF-8"]);
|
||||
let many = "{\"command\":\"select.all\"}\n".repeat(100_001);
|
||||
|
||||
Reference in New Issue
Block a user