#Attribute Creation
1 messages · Page 1 of 1 (latest)
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 🙏
entity user {}
entity organization {
// organizational roles
relation admin @user
relation member @user
}
entity repository {
// represents repositories parent organization
relation parent @organization
// represents owner of this repository
relation owner @user
// permissions
permission edit = parent.admin or owner
permission delete = owner
}
I have tried with the same schema that's in the playground
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.
Okay, let me try
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": []
}
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?
We have installed the latest version but the issue persists. How can we check the version upgraded or not?
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": {}
}```
The error has been resolved, and got the the response is as follows, but the tuple still exists, and it was not removed.
{
"snap_token": "WSgBAAAAAAA="
}
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.
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": ""
}
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.
Yes, it worked. thank you
You're welcome
Where the snap_token is stored, I have searched in the back-end table and found it?
This is the Base64-encoded version of the last transaction ID in the database. You can find it inside the transactions table, but we do not yet have an API to provide this for you directly. For information on how to use this, you can review the following section on our documentation: https://docs.permify.co/docs/api-overview/data/write-data/#two-phase-commit-approach
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?