This message was deleted.
# general
m
This message was deleted.
m
Hey Luka, yea if you could give me some hints on how to reproduce this, would be helpful. Just how to create “wrong” relationship, etc.
👍 1
w
Hi @magnificent-energy-493. Here is Namespaces:
Copy code
import { Namespace, SubjectSet, Context } from "@ory/permission-namespace-types"

class Identity implements Namespace { }

class Supportal implements Namespace {
  related: {
    viewers: (Identity | Supportal)[]
    editors: (Identity | Supportal)[]
  }

  permits = {
    view: (ctx: Context): boolean =>
      this.related.viewers.includes(ctx.subject) ||
      this.related.editors.includes(ctx.subject),

    edit: (ctx: Context): boolean =>
      this.related.editors.includes(ctx.subject)
  }
}

class Bizops implements Namespace {
  related: {
    parents: Supportal[]
    viewers: (Identity | SubjectSet<Supportal, "viewers">)[]
    editors: (Identity | SubjectSet<Supportal, "editors">)[]
  }

  permits = {
    view: (ctx: Context): boolean =>
      this.related.viewers.includes(ctx.subject) ||
      this.related.editors.includes(ctx.subject) ||
      this.related.parents.traverse((p) => p.permits.view(ctx)) ||
      this.related.parents.traverse((p) => p.permits.edit(ctx)),

    edit: (ctx: Context): boolean =>
      this.related.viewers.includes(ctx.subject) ||
      this.related.editors.includes(ctx.subject) ||
      this.related.parents.traverse((p) => p.permits.edit(ctx)),
  }
}
Copy code
Here is relationship I ran:

[
  {
    "namespace": "Supportal",
    "object": "bizops",
    "relation": "editors",
    "subject_set": {
      "namespace": "Identity",
      "object": "luka"
    }
  },
  {
    "namespace": "Supportal",
    "object": "bizops",
    "relation": "viewers",
    "subject_set": {
      "namespace": "Identity",
      "object": "david"
    }
  },
  {
    "namespace": "Bizops",
    "object": "task",
    "relation": "viewers",
    "subject_set": {
      "namespace": "Supportal",
      "object": "bizops"
    }
  }
]
If you run this form CLI
ory create relationships r.json
, most likely you will get the same issue. I think the problem is with
relation
field which I did not specify. So this is correct syntax I guess
Copy code
"subject_set": {
  "namespace": "Supportal",
  "object": "bizops",
  "relation": "viewers"
}
p
I also just ran into this issue. Did you find a resolution?
f
@magnificent-energy-493 were you able to reproduce this? i also just ran into it
Managed to resolve this by creating a relationship through the rest api
m
not yet sorry, @steep-lamp-91158 did you come across this before?
s
hm the undefined response type is an annoyance from our auto-generated SDKs... I guess this can happen on various API calls, using CURL instead should give you the exact error message