From 09ebc083318eed13d3d2bb819ee7481e86f1d3a7 Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Wed, 30 Oct 2024 11:59:27 -0600 Subject: [PATCH 1/3] Rename function to clarify lack of caveat --- pkg/tuple/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } From af89e978878e8fd7f50ca8e03ecc5a3ca8b07f62 Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Wed, 30 Oct 2024 11:59:42 -0600 Subject: [PATCH 2/3] Add MustParseV1 for test purposes --- pkg/tuple/v1.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 { From 75b33680161cebbfa522edbb6917a44b9e52c896 Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Wed, 30 Oct 2024 12:00:02 -0600 Subject: [PATCH 3/3] Update usage of renamed fn --- pkg/development/devcontext.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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), }) }