-
Notifications
You must be signed in to change notification settings - Fork 267
Prevent silent (ish) failure of agent validation #1838
Conversation
… prevents confusion between validation failures and actual errors
crates/core_types/src/dna/mod.rs
Outdated
}) | ||
.filter_map(|r| match r { | ||
Ok(_) => None, | ||
Err(e) => Some(e.to_owned()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r.err() will return an option so we could probably change this to filter_map(|r| r.err())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
crates/core_types/src/dna/mod.rs
Outdated
Err(e) => Some(e.to_owned()), | ||
}) | ||
.collect(); | ||
if errors.len() == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors.is_empty()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some code clean up suggestions but looks good
Closes #1824
Issue description
This issue stemmed from artifacts in the .dna.json file. As the
validate_agent
callback must be run for all zomes in a DNA it iterates over everything in thezomes
field. If there is a __META.. field in the zome object it will include this and try to use it to run the validation callback.Instead of producing a proper error it just assumed the failure of validation of an agent and this is why links could not be retrieved off their address.
Fix
This adds several fixes to prevent this bug
Validation callbacks will explicitly panic if an unknown error occurs. This seems more appropriate than assuming all errors mean a validation failure (in this case it is a corrupt DNA failure)
Adds a check on loading a .dna.json file that all the
code
fields in zomes contain some code (in future check they all have the required callbacks)Update the
hc package
tool to not dump __META stuff in json by default.--strip-meta
flag is now--include-meta.
PR summary
testing/benchmarking notes
( if any manual testing or benchmarking was/should be done, add notes and/or screenshots here )
followups
( any new tickets/concerns that were discovered or created during this work but aren't in scope for review here )
changelog
documentation