Skip to content

Commit 84284c6

Browse files
factorydroidFactory Bot
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 5579873 commit 84284c6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cortex-cli/src/import_cmd.rs

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

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

5762
// Validate version
5863
if export.version != 1 {

0 commit comments

Comments
 (0)