Skip to content

Commit 9c70ccf

Browse files
authored
update error text when relationship is invalid (#69)
1 parent eec0fc5 commit 9c70ccf

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/spicedb-common/parsing.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,79 +50,79 @@ describe("parsing relationships", () => {
5050
const relationship = "";
5151
expect(parseRelationshipWithError(relationship)).toEqual({
5252
errorMessage:
53-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
53+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
5454
});
5555
});
5656

5757
it("returns an error for a relationship missing an object", () => {
5858
const relationship = "somenamespace#somerel@someuser:foo";
5959
expect(parseRelationshipWithError(relationship)).toEqual({
6060
errorMessage:
61-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
61+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
6262
});
6363
});
6464

6565
it("returns an error for a relationship missing a subject", () => {
6666
const relationship = "somenamespace:something#somerel";
6767
expect(parseRelationshipWithError(relationship)).toEqual({
6868
errorMessage:
69-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
69+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
7070
});
7171
});
7272

7373
it("returns an error for a relationship with an invalid namespace", () => {
7474
const relationship = "a:something#somerel@user:foo";
7575
expect(parseRelationshipWithError(relationship)).toEqual({
7676
errorMessage:
77-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
77+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
7878
});
7979
});
8080

8181
it("returns an error for a relationship with an invalid object id", () => {
8282
const relationship = "document:some.thing#somerel@user:foo";
8383
expect(parseRelationshipWithError(relationship)).toEqual({
8484
errorMessage:
85-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
85+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
8686
});
8787
});
8888

8989
it("returns an error for a relationship with a wildcard resource id", () => {
9090
const relationship = "document:*#somerel@user:foo";
9191
expect(parseRelationshipWithError(relationship)).toEqual({
9292
errorMessage:
93-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
93+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
9494
});
9595
});
9696

9797
it("returns an error for a relationship with an invalid relation", () => {
9898
const relationship = "document:something#a@user:foo";
9999
expect(parseRelationshipWithError(relationship)).toEqual({
100100
errorMessage:
101-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
101+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
102102
});
103103
});
104104

105105
it("returns an error for a relationship with an invalid subject namespace", () => {
106106
const relationship = "document:something#somerel@a:foo";
107107
expect(parseRelationshipWithError(relationship)).toEqual({
108108
errorMessage:
109-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
109+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
110110
});
111111
});
112112

113113
it("returns an error for a relationship with an invalid subject object id", () => {
114114
const relationship = "document:something#somerel@user:some.thing";
115115
expect(parseRelationshipWithError(relationship)).toEqual({
116116
errorMessage:
117-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
117+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
118118
});
119119
});
120120

121121
it("returns an error for a relationship with an invalid subject relation", () => {
122122
const relationship = "document:something#somerel@user:someuser#a";
123123
expect(parseRelationshipWithError(relationship)).toEqual({
124124
errorMessage:
125-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
125+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
126126
});
127127
});
128128

src/spicedb-common/parsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const parseRelationshipWithError = (
9494
if (!parsed || !parsed.groups) {
9595
return {
9696
errorMessage:
97-
"Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid`",
97+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
9898
};
9999
}
100100

0 commit comments

Comments
 (0)