Error: "Failed to validate agent ID on a zome" since hdk 0.0.25

I get the following errors since hdk 0.0.25:
It happens at start, and also with the default zome code generated by hc (my_entry)

WARN 2019-09-20 20:13:20 [holochain::test-instance] store_entry_content/puid-3-4 /Users/me/.cargo/git/checkouts/holochain-rust-c3b6365fc5bfa642/7d38b33/core/src/workflows/hold_entry.rs:82 workflow/hold_entry: Entry HcSCiusMpqD9tfas5yOKZ5cOkYsqrkwaoK8a3oBR7J6Yjpz3ztxmsOeDkgbthfz is NOT valid! Validation error: Error(ErrorGeneric("Failed to validate agent ID on a zome, [Error(ErrorGeneric(\"I/O Error: UnexpectedEof\"))]"))
ERROR 2019-09-20 20:13:20 [holochain::test-instance] store_entry_content/puid-3-4 /Users/me/.cargo/git/checkouts/holochain-rust-c3b6365fc5bfa642/7d38b33/core/src/network/handler/store.rs:35 net/dht: Failed to validate agent ID on a zome, [Error(ErrorGeneric("I/O Error: UnexpectedEof"))]

Any idea what it might be related to ?
It seems that my genesis function is failing since 0.0.29, and it could be linked (for info my genesis function is only trying to insert data linked to the agent’s pubKey)

Thanks in advance

Can you post the screenshot of your zome code and provide more details?

https://developer.holochain.org/guide/latest/zome/validate_agent.html

Sure. It’s pretty much the default app generated by hc generate zomes/myentry, so here’s the folder structure:

For the validate_agent() function I tried both with only returning Ok(()) and with the example given in the docs page you sent me.

And then here’s the content of the key files:

lib.rs

#[macro_use]
extern crate hdk;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
#[macro_use]
extern crate holochain_json_derive;

use hdk::{
    entry_definition::ValidatingEntryType,
    error::ZomeApiResult,
    EntryValidationData,
};
use hdk::holochain_core_types::{
    entry::Entry,
    dna::entry_types::Sharing,
    agent::AgentId,
};

use hdk::holochain_persistence_api::{
    cas::content::Address,
};

use hdk::holochain_json_api::{
    error::JsonError,
    json::JsonString,
};


// see https://developer.holochain.org/api/0.0.25-alpha1/hdk/ for info on using the hdk library

// This is a sample zome that defines an entry type "MyEntry" that can be committed to the
// agent's chain via the exposed function create_my_entry

#[derive(Serialize, Deserialize, Debug, DefaultJson,Clone)]
pub struct MyEntry {
    content: String,
}

pub fn handle_create_my_entry(entry: MyEntry) -> ZomeApiResult<Address> {
    let entry = Entry::App("my_entry".into(), entry.into());
    let address = hdk::commit_entry(&entry)?;
    Ok(address)
}

pub fn handle_get_my_entry(address: Address) -> ZomeApiResult<Option<Entry>> {
    hdk::get_entry(&address)
}

fn definition() -> ValidatingEntryType {
    entry!(
        name: "my_entry",
        description: "this is a same entry defintion",
        sharing: Sharing::Public,
        validation_package: || {
            hdk::ValidationPackageDefinition::Entry
        },

        validation: | _validation_data: hdk::EntryValidationData<MyEntry>| {
            Ok(())
        }
    )
}

define_zome! {
    entries: [
       definition()
    ]

    init: || { Ok(()) }

    validate_agent: |validation_data : EntryValidationData::<AgentId>| {{
        if let EntryValidationData::Create{entry, ..} = validation_data {
            let agent = entry as AgentId;
            if agent.nick == "reject_agent::app" {
                Err("This agent will always be rejected".into())
            } else {
                Ok(())
            }
        } else {
            Err("Cannot update or delete an agent at this time".into())
        }
    }}

    functions: [
        create_my_entry: {
            inputs: |entry: MyEntry|,
            outputs: |result: ZomeApiResult<Address>|,
            handler: handle_create_my_entry
        }
        get_my_entry: {
            inputs: |address: Address|,
            outputs: |result: ZomeApiResult<Option<Entry>>|,
            handler: handle_get_my_entry
        }
    ]

    traits: {
        hc_public [create_my_entry,get_my_entry]
    }
}

The conductor config is (template, gets generated by a makefile, see below):

bridges = []
persistence_dir = ''
ui_bundles = []
ui_interfaces = []

[[agents]]
id = 'hc-run-agent'
keystore_file = 'testAgent'
name = 'testAgent'
public_address = 'HcScjN8wBwrn3tuyg89aab3a69xsIgdzmX5P9537BqQZ5A7TEZu7qCY4Xzzjhma'
test_agent = true

[[dnas]]
file = "{{ c.DNA_FILE_PATH }}"
hash = "{{ c.DNA_HASH }}"
id = 'hc-run-dna'

[[instances]]
agent = 'hc-run-agent'
dna = 'hc-run-dna'
id = 'test-instance'
    [instances.storage]
    type = 'memory'

[[interfaces]]
admin = true
id = 'websocket-interface'
    [interfaces.driver]
    port = 8888
    type = 'websocket'
    [[interfaces.instances]]
    id = 'test-instance'
[[interfaces]]
admin = true
id = 'http-interface'
    [interfaces.driver]
    port = 4000
    type = 'http'
    [[interfaces.instances]]
    id = 'test-instance'


# ---------  Network  ----------

[network]
bootstrap_nodes = [
    "wss://172.31.1.100:35268/?a=HcSCi6pCTkizyxh3u3yUzRaksU67abdfa7Cmjc83szhf89th7d69fNwvRS5t6ui"
]
n3h_log_level = 'i'
n3h_mode = 'REAL'
n3h_persistence_path = '{{ c.NH3_FOLDER }}'
type = 'n3h'

# ----------  Other  -----------

[passphrase_service]
type = 'cmd'

[signals]
consistency = false
trace = false

# ----------  Logs  -----------

[logger]
state_dump = true
type = 'debug'
    [[logger.rules.rules]]
    exclude = true
    pattern = '.*'
    [[logger.rules.rules]]
    exclude = false
    pattern = '^holochain'
    [[logger.rules.rules]]
    exclude = false
    pattern = '^lib3h'

And I launch the whole thing with a makefile (I’ll including only the key lines here)

.DEFAULT_GOAL := hcconf
hcconf: deps gen-keys build 
	@tera -f hcconf_tpl.toml --env > .cache/hcconf.gen.toml
	holochain -c .cache/hcconf.gen.toml
build:
	hc package -o ${DNA_FILE_PATH}

# deps sets holochain and hc to 0.0.29, and rust to 1.38-nightly
# tera is what renders the holochain_config template

Thanks in advance

Hi @nmrshll
I believe this is actually a bug.
I’m also getting the same thing. I’ll make an issue on the github and have a look at solving it. Hopefully it’s not blocking you.

Thanks for the detailed report.

Great to know it’s not just me.

And thanks for taking the feedback into consideration.

When you have the issue created, do you mind posting a link back here for anyone (including me) to follow the progress on it ?
Thanks

Looks like someone else has already opened an issue for this. I added a comment to it thought and will start having a dig.

Looks like I know that someone else and have a pretty short memory :slight_smile: Thanks for putting the link here

1 Like

Oh I didn’t even pick up on that haha

This is now fixed. It was a strange bug that only sometimes appeared and was to do with artifacts in the .dna.json being treated as zomes when they are not. Because validate_agent needs to run the callback in every zome this was causing an EOF error. Rebuilding with a never version of the hc tool should fix this for you.

1 Like

Thank you !