Skip to content

Commit 0eb8c66

Browse files
authored
registry: More warnings when skipping a collection (#21)
1 parent 431bd89 commit 0eb8c66

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/registry.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,26 @@ pub fn read_devcontainer_index<P: AsRef<Path>>(filename: P) -> Result<Devcontain
474474
let parsed = arr
475475
.iter()
476476
.filter_map(|value| {
477-
let source_information: SourceInformation = value
477+
let source_information: SourceInformation = match value
478478
.get("sourceInformation")
479-
.and_then(|value| serde_json::from_value(value.to_owned()).ok())?;
480-
let features = value.get("features").and_then(|value| value.as_array())?;
479+
.and_then(|value| serde_json::from_value(value.to_owned()).ok())
480+
{
481+
Some(value) => Some(value),
482+
None => {
483+
log::warn!("Skipping collection due to parsing error of sourceInformation");
484+
None
485+
},
486+
}?;
487+
let features = match value.get("features").and_then(|value| value.as_array()) {
488+
Some(arr) => Some(arr),
489+
None => {
490+
log::warn!(
491+
"Skipping collection due to parse error. The `features` field is not an array. Collection.oci_ref = {}",
492+
&source_information.oci_reference
493+
);
494+
None
495+
},
496+
}?;
481497
let features = features
482498
.iter()
483499
.flat_map(|value| match serde_json::from_value::<Feature>(value.to_owned()) {
@@ -494,7 +510,16 @@ pub fn read_devcontainer_index<P: AsRef<Path>>(filename: P) -> Result<Devcontain
494510
},
495511
})
496512
.collect();
497-
let templates = value.get("templates").and_then(|value| value.as_array())?;
513+
let templates = match value.get("templates").and_then(|value| value.as_array()) {
514+
Some(arr) => Some(arr),
515+
None => {
516+
log::warn!(
517+
"Skipping collection due to parsing error. The `templates` field is not an array. Collection.oci_ref = {}",
518+
&source_information.oci_reference,
519+
);
520+
None
521+
},
522+
}?;
498523
let templates = templates
499524
.iter()
500525
.flat_map(|value| match serde_json::from_value::<Template>(value.to_owned()) {

0 commit comments

Comments
 (0)