Error running unhas: RelationshipReified cannot be cast to Relationship


I get the following error trying to run “unhas” in the python client

grakn.exception.GraknError.GraknError: Server/network error: <_Rendezvous of RPC that terminated with:
	status = StatusCode.UNKNOWN
	details = "ai.grakn.kb.internal.concept.RelationshipReified cannot be cast to ai.grakn.concept.Relationship. Please check server logs for the stack trace."
	debug_error_string = "{"created":"@1543441514.659025000","description":"Error received from peer","file":"src/core/lib/surface/","file_line":1017,"grpc_message":"ai.grakn.kb.internal.concept.RelationshipReified cannot be cast to ai.grakn.concept.Relationship. Please check server logs for the stack trace.","grpc_status":2}"

Here is a program that reproduces the error against an empty keyspace:

import grakn

GRAKN_CLIENT = grakn.Grakn(uri="localhost:48555")
GRAKN_SESSION = GRAKN_CLIENT.session(keyspace="demo2")

with GRAKN_SESSION.transaction(grakn.TxType.WRITE) as tx:
        group sub entity plays member_of;
        person sub entity plays member;
        membership sub relationship relates member relates member_of has name;
        name sub attribute datatype string;

        $p isa person;
        $g isa group;
        (member: $p, member_of: $g) isa membership has name "founder";
    membership = tx.query('match $x isa membership; get;').collect_concepts()[0]
    for attr in membership.attributes():

I am running grakn 1.4.2, python client 1.4.2

I don’t know if I’m using unhas or attributes wrong, or if this is a grakn bug

Edit 2018-11-29: replaced membership.keys() with membership.attributes()


What I’m trying to do in my real dataset is “update” the “field”, as if the membership relationship is a record in a table. has() will add an attribute to the thing; I’m instead trying to replace the attribute with a new value

Update exiting data

There’s a subtle difference between attributes and attributes that are keys: attributes attached to things as keys are checked to be unique for the given type and declared in the schema with the key keyword:

membership sub relationship, relates member, relates member_of, key name; # unique attribute for `membership`


membership sub relationship, relates member, relates member_of, has name;  # just an attribute

the .keys() functionality returns any keys attached to the Thing. Since you’ve not defined any keys, try to get the attribute with .attributes(). If you intend to use keys, I don’t think we currently support deleting keys off of Things.

Hope that helps!


I was not aware keys existed. They aren’t mentioned at . Regardless, I still get the same error if I replace

for attr in membership.keys():


for attr in membership.attributes():


@soroush is currently hard at work at upating documentation for 1.5, which we’re all looking forward to seeing!

Regarding the unhas problem, it appears to be a bug when trying to remove an attribute from a relationship; the operation should be fine on entities (& I imagine attributes on attributes too).

@kasper I can confirm the error is the one given in the first post - RelationshipReified vs Relationship casting problems. I’ll make an issue for it.

Thanks for finding the bug and helping us improve Grakn!