Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print a more meaningful message when decoding an object fails. #917

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,12 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
manifest_bytes.clone(), self.run.validation.strict
) {
Ok(manifest) => manifest,
Err(err) => {
Err(_) => {
self.metrics.invalid_manifests += 1;
warn!("{}: {}.", self.cert.rpki_manifest(), err);
warn!(
"{}: failed to decode manifest.",
self.cert.rpki_manifest()
);
return Ok(None)
}
};
Expand Down Expand Up @@ -916,9 +919,9 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
// Decode and validate the CRL.
let mut crl = match Crl::decode(crl_bytes.clone()) {
Ok(crl) => crl,
Err(err) => {
Err(_) => {
self.metrics.invalid_crls += 1;
warn!("{}: {}.", crl_uri, err);
warn!("{}: failed to decode CRL.", crl_uri);
return Ok(None)
}
};
Expand Down Expand Up @@ -1048,8 +1051,11 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
stored_manifest.manifest().clone(), self.run.validation.strict
) {
Ok(manifest) => manifest,
Err(err) => {
warn!("{}: {}.", self.cert.rpki_manifest(), err);
Err(_) => {
warn!(
"{}: failed to decode manifest.",
self.cert.rpki_manifest(),
);
self.metrics.invalid_manifests += 1;
return Err(Failed);
}
Expand Down Expand Up @@ -1096,8 +1102,8 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
// Decode and validate the CRL.
let mut crl = match Crl::decode(stored_manifest.crl().clone()) {
Ok(crl) => crl,
Err(err) => {
warn!("{}: {}.", crl_uri, err);
Err(_) => {
warn!("{}: failed to decode CRL.", crl_uri);
self.metrics.invalid_manifests += 1;
self.metrics.invalid_crls += 1;
return Err(Failed)
Expand Down Expand Up @@ -1242,8 +1248,8 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
) -> Result<(), Failed> {
let cert = match Cert::decode(content) {
Ok(cert) => cert,
Err(err) => {
warn!("{}: {}.", uri, err);
Err(_) => {
warn!("{}: failed to decode certificate.", uri);
manifest.metrics.invalid_certs += 1;
return Ok(())
}
Expand Down Expand Up @@ -1357,8 +1363,8 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
content, self.run.validation.strict
) {
Ok(roa) => roa,
Err(err) => {
warn!("{}: {}.", uri, err);
Err(_) => {
warn!("{}: failed to decode ROA.", uri);
manifest.metrics.invalid_roas += 1;
return Ok(())
}
Expand Down Expand Up @@ -1391,8 +1397,8 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
content, self.run.validation.strict
) {
Ok(aspa) => aspa,
Err(err) => {
warn!("{}: {}.", uri, err);
Err(_) => {
warn!("{}: failed to decode ASPA.", uri);
manifest.metrics.invalid_aspas += 1;
return Ok(())
}
Expand Down Expand Up @@ -1424,8 +1430,8 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
content, self.run.validation.strict
) {
Ok(obj) => obj,
Err(err) => {
warn!("{}: {}.", uri, err);
Err(_) => {
warn!("{}: failed to decode GBR.", uri);
manifest.metrics.invalid_gbrs += 1;
return Ok(())
}
Expand Down
Loading