Skip to content

Commit df08b35

Browse files
factorydroidechobt
authored andcommitted
fix(cortex-cli): exit with non-zero code on JSON parse failure in import command
Fixes bounty issue #1536 The import command was printing an error message when encountering malformed JSON but exiting with code 0. This fix ensures the process exits with code 1 when JSON parsing fails, allowing scripts and CI pipelines to properly detect the error condition.
1 parent 9b86760 commit df08b35

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

cortex-cli/src/import_cmd.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ impl ImportCommand {
5454
};
5555

5656
// Parse the export
57-
let export: SessionExport = serde_json::from_str(&json_content)
58-
.with_context(|| "Failed to parse session export JSON")?;
57+
let export: SessionExport = match serde_json::from_str(&json_content) {
58+
Ok(export) => export,
59+
Err(e) => {
60+
eprintln!("Error: Failed to parse session export JSON: {e}");
61+
std::process::exit(1);
62+
}
63+
};
5964

6065
// Validate version
6166
if export.version != 1 {

0 commit comments

Comments
 (0)