Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Prevent silent (ish) failure of agent validation #1838

Merged
merged 9 commits into from
Nov 7, 2019

Conversation

willemolding
Copy link
Collaborator

@willemolding willemolding commented Nov 7, 2019

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 the zomes 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

  • if this is a code change that effects some consumer (e.g. zome developers) of holochain core, then it has been added to our between-release changelog with the format
- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)

documentation

})
.filter_map(|r| match r {
Ok(_) => None,
Err(e) => Some(e.to_owned()),
Copy link
Contributor

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())

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Err(e) => Some(e.to_owned()),
})
.collect();
if errors.len() == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors.is_empty()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@StaticallyTypedAnxiety StaticallyTypedAnxiety left a 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

@lucksus lucksus merged commit 8ffd987 into develop Nov 7, 2019
@neonphog neonphog deleted the bugfix/silent-agent-validation-failure branch March 5, 2020 23:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link from AGENT_ADDRESS not working
3 participants