diff --git a/crates/core/src/curation/legacy/report.rs b/crates/core/src/curation/legacy/report.rs index 83fa96f8..99a10da2 100644 --- a/crates/core/src/curation/legacy/report.rs +++ b/crates/core/src/curation/legacy/report.rs @@ -200,8 +200,10 @@ fn text_at<'a>(value: &'a Value, pointer: &str) -> &'a str { } fn categories_section(result: &ImportResult) -> String { - let legacy_of: HashMap<&str, &str> = result.legacy_id_map["categories"] - .as_object() + let legacy_of: HashMap<&str, &str> = result + .legacy_id_map + .get("categories") + .and_then(Value::as_object) .map(|map| { map.iter() .filter_map(|(k, v)| Some((v.as_str()?, k.as_str()))) @@ -286,7 +288,11 @@ fn vertebral_section(result: &ImportResult) -> String { .region_inferences .iter() .map(|i| { - let new_id = result.legacy_id_map["annotations"][&i.annotation_id].as_str(); + let new_id = result + .legacy_id_map + .get("annotations") + .and_then(|map| map.get(&i.annotation_id)) + .and_then(Value::as_str); vec![ code(Some(new_id.unwrap_or(&i.annotation_id))).into(), i.label.as_str().into(),