diff --git a/pkg/development/devcontext.go b/pkg/development/devcontext.go index 9b43b9f418..d065937002 100644 --- a/pkg/development/devcontext.go +++ b/pkg/development/devcontext.go @@ -97,7 +97,7 @@ func newDevContextWithDatastore(ctx context.Context, requestContext *devinterfac Message: err.Error(), Source: devinterface.DeveloperError_RELATIONSHIP, Kind: devinterface.DeveloperError_PARSE_ERROR, - Context: tuple.CoreRelationToString(rel), + Context: tuple.CoreRelationToStringWithoutCaveat(rel), }) } diff --git a/pkg/tuple/core.go b/pkg/tuple/core.go index c81997aee1..957cbcaf09 100644 --- a/pkg/tuple/core.go +++ b/pkg/tuple/core.go @@ -19,7 +19,7 @@ func ONRStringToCore(ns, oid, rel string) *core.ObjectAndRelation { } // CoreRelationToString creates a string from a core.RelationTuple. -func CoreRelationToString(rel *core.RelationTuple) string { +func CoreRelationToStringWithoutCaveat(rel *core.RelationTuple) string { if rel.Subject.Relation == Ellipsis { return rel.ResourceAndRelation.Namespace + ":" + rel.ResourceAndRelation.ObjectId + "@" + rel.Subject.Namespace + ":" + rel.Subject.ObjectId } diff --git a/pkg/tuple/v1.go b/pkg/tuple/v1.go index 8fbca99c33..06c064f62b 100644 --- a/pkg/tuple/v1.go +++ b/pkg/tuple/v1.go @@ -20,6 +20,16 @@ func ParseV1Rel(relString string) (*v1.Relationship, error) { return ToV1Relationship(parsed), nil } +// Same as above, but panics if it cannot be parsed. Should only be used in tests. +func MustParseV1Rel(relString string) (*v1.Relationship, error) { + parsed, err := Parse(relString) + if err != nil { + panic(fmt.Sprintf("could not parse relationship string: %s %s", relString, err)) + } + + return ToV1Relationship(parsed), nil +} + // MustV1RelString converts a relationship into a string. Will panic if // the Relationship does not validate. func MustV1RelString(rel *v1.Relationship) string {