openfga / openfga/language

Add a JSON Schema for what the JSON model should look like and validate against invalid JSON input

Open
#158 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
35
Forks
17
Avg merge
48m
Merged PRs (30d)
10

Description

See: https://github.com/openfga/openfga/issues/1164

The below model is invalid because the intersection definition in the document#viewer relation is malformed. It’s missing a child: […] nested block.

{
  "schema_version": "1.1",
  "type_definitions": [
    {
        "type": "user"
    },
    {
        "type": "folder",
        "relations": {
            "viewer": {"this": {}},
            "parent": {"this": {}}
        },
        "metadata": {
            "relations": {
                "viewer": {
                    "directly_related_user_types": [{"type": "user"}]
                },
                "parent": {
                    "directly_related_user_types": [{"type": "folder"}]
                }
            }
        }
    },
    {
        "type": "document",
        "relations": {
            "parent": {"this": {}},
            "viewer": {
                "union": {
                    "child": [
                        {
                            "intersection": {
                                "tupleToUserset": {
                                    "tupleset": {
                                        "relation": "parent"
                                    },
                                    "computedUserset": {
                                        "relation": "viewer"
                                    }
                                }
                            }
                        },
                        {"this": {}}
                    ]
                }
            }
        },
        "metadata": {
            "relations": {
                "parent": {
                    "directly_related_user_types": [{"type": "folder", "relation": "parent"}]
                },
                "viewer": {
                    "directly_related_user_types": [{"type": "user"}]
                }
            }
        }
    }
  ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue provides a malformed JSON model in its body and links to openfga/openfga#1164, but names no files, tests, or validation entry point. Start by locating the JSON model representation and its current parsing or validation path. Done means a JSON Schema exists and invalid input such as the supplied intersection example is rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, json
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.