#Attribute Creation

1 messages · Page 1 of 1 (latest)

serene grove
#

Could you send your current schema ?

#

@autumn crane Could you please resend the schema with formatting it? You can do it on our playground. Also, it's better to keep the conversation in this thread, so please message me through here. Thanks in advance 🙏

autumn crane
#

I have tried with the same schema that's in the playground

serene grove
#

The error (ERROR_CODE_ATTRIBUTE_DEFINITION_NOT_FOUND ) is ocurring because you need to define related attribute, in your case you should define attribute private @boolean in the organization entity to be able to create a data for it. Likewise the relation tuples.

#

You can check out the section: https://docs.permify.co/docs/getting-started/modeling/#defining-attribute-based-permissions for modeling attributes in the schema.

Permify has its own language that you can model your authorization logic with it. The language allows to define arbitrary relations between users and objects, such as owner, editor, commenter or roles like admin, manager, member and also dynamic attributes such as boolean variables, IP range, time period, etc.

autumn crane
#

Please consider the provided JSON data. When I attempted to delete the specified tuple with entity '2' and subject ID '5' using the given request, it resulted in the response: 'Invalid DataDeleteRequest.TupleFilter: value is required'.

{
"tuples": [
{
"entity": {
"type": "organization",
"id": "2"
},
"relation": "admin",
"subject": {
"type": "user",
"id": "4",
"relation": ""
}
},
{
"entity": {
"type": "organization",
"id": "2"
},
"relation": "member",
"subject": {
"type": "user",
"id": "4",
"relation": ""
}
},
{
"entity": {
"type": "organization",
"id": "2"
},
"relation": "member",
"subject": {
"type": "user",
"id": "5",
"relation": ""
}
}
],
"continuous_token": ""
}

Request: http://localhost:3476/v1/tenants/t5/data/delete
{
"tupleFilter": {
"entity": {
"type": "organization",
"ids": ["2"]
},
"relation": "member",
"subject": {
"type": "user",
"ids": ["5"],
"relation": ""
}
}
}

Response:
{
"code": 3,
"message": "invalid DataDeleteRequest.TupleFilter: value is required",
"details": []
}

terse arrow
#

Hello @autumn crane ,

In previous versions, there was a required validation that applied to both filters. You can view the details of the issue at https://github.com/Permify/permify/issues/788. We addressed this in version 0.5.6. Could you please update to version 0.5.6 and test it?

autumn crane
terse arrow
#

You can check the version using the permify version command.

#

Could you please try the following?

#
  "tuple_filter": {
    "entity": {
      "type": "organization",
      "ids": ["2"]
    },
    "relation": "member",
    "subject": {
      "type": "user",
      "ids": ["5"],
      "relation": ""
    }
  },
  "attribute_filter": {}
}```
autumn crane
terse arrow
#

If you're checking directly in the database, please note that Permify uses the Multi-Version Concurrency Control (MVCC) pattern. This means what you're seeing in the database has actually been deleted. You can verify this by checking the created_tx_id and expired_tx_id. For more details, you can refer to this link: (http://mbukowicz.github.io/databases/2020/05/01/snapshot-isolation-in-postgresql.html). When you send a check request with the snap token you provided (if you haven't written a specific state, it uses the head snapshot), these deleted data will not appear. This is also the foundation of our caching mechanism.

autumn crane
# terse arrow If you're checking directly in the database, please note that Permify uses the M...

Not in the database, I am checking this through the API "http://localhost:3476/v1/tenants/t5/data/relationships/read". The request and response is given as follows.
Request:
{
"metadata": {
"snap_token": "UCgBAAAAAAA="
},
"filter": {
"entity": {
"type": "organization",
"ids": ["2"]
},
"relation": "",
"subject": {
"type": "",
"ids": [],
"relation": ""
}
},
"page_size": 0,
"continuous_token": ""
}

Response:
{
"tuples": [
{
"entity": {
"type": "organization",
"id": "2"
},
"relation": "admin",
"subject": {
"type": "user",
"id": "4",
"relation": ""
}
},
{
"entity": {
"type": "organization",
"id": "2"
},
"relation": "member",
"subject": {
"type": "user",
"id": "4",
"relation": ""
}
},
{
"entity": {
"type": "organization",
"id": "2"
},
"relation": "member",
"subject": {
"type": "user",
"id": "5",
"relation": ""
}
}
],
"continuous_token": ""
}

terse arrow
#

Yes, it seems you are using an old snap token, which represents an outdated view of the database. You need to use the snap token that you obtained after the deletion, like so:

"metadata": {
  "snap_token": "WSgBAAAAAAA="
}

If you leave it empty, the system will operate with the most recent snapshot.

terse arrow
#

You're welcome

autumn crane
terse arrow
#

The easiest way to use it is to leave it blank. When left blank, it will default to the most recent transaction, which means you don't need to store it. This may slightly affect performance. How important is performance to you?