Skip to content

Conversation

aaguiarz
Copy link
Member

@aaguiarz aaguiarz commented Jul 2, 2025

Summary

  • allow reading tuples in JSONL format
  • document JSONL format for tuple import
  • test JSONL parsing for write/delete commands
  • add JSONL fixtures for integration tests

Testing

  • make test (fails: docker not found)

https://chatgpt.com/codex/tasks/task_e_68652d7d38408322b8aac442bc24a5a9

Summary by CodeRabbit

  • New Features

    • Added support for reading and writing tuple files in JSON Lines (jsonl) format.
    • Documentation updated to reflect jsonl support and provide usage examples.
    • Enhanced model relations with a new conditional constraint based on IP address.
  • Tests

    • Expanded test coverage to include parsing, error handling, and command execution with jsonl files.
    • Added new test data and fixtures for jsonl format.

Copy link
Contributor

coderabbitai bot commented Jul 2, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

## Walkthrough

Support for the JSON Lines (`.jsonl`) file format was added for reading and parsing tuple data in the application. Documentation, code, and tests were updated to handle `.jsonl` files for tuple write and delete commands, including examples and new test cases. New fixture and test data files in `.jsonl` format were also introduced.

## Changes

| File(s)                                                      | Change Summary                                                                                                                      |
|--------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| README.md                                                    | Updated documentation to mention `.jsonl` support for tuple write/delete commands and added usage examples.                         |
| internal/tuplefile/read.go                                   | Added JSONL parsing support with a new helper function; updated main reader to handle `.jsonl` files.                               |
| cmd/tuple/write_test.go, cmd/tuple/delete_test.go            | Added test cases to verify correct parsing and error handling for `.jsonl` tuple files.                                             |
| cmd/tuple/testdata/tuples.jsonl, tests/fixtures/basic-tuples.jsonl | Added new JSONL test data and fixture files with tuple entries for use in tests.                                                    |
| tests/tuple-test-cases.yaml                                  | Added a new test case to verify tuple writing using a `.jsonl` file as input.                                                       |
| tests/fixtures/basic-model.fga                              | Expanded `owner` relation in `group` type to include a new `inOfficeIP` condition checking IP address within a CIDR range.          |
| tests/fixtures/basic-tuples.json                            | Added a trailing newline character at the end of the file.                                                                          |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant CLI
    participant TupleFileReader
    participant Store

    User->>CLI: Run tuple write/delete with --file file.jsonl
    CLI->>TupleFileReader: ReadTupleFile(file.jsonl)
    TupleFileReader->>TupleFileReader: parseTuplesFromJSONL(data)
    TupleFileReader-->>CLI: Parsed tuples
    CLI->>Store: Write/Delete tuples
    Store-->>CLI: Operation result
    CLI-->>User: Output result

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAQVp6ACkAZQB5ADkAGTDsbkiUZm58ClCHbiKS6Mg5SGxESnQ0Imx4ZwAvFAxcCkVsBmlIADNsDDF4fAw0L3V5AnQffAB3PxI0WngMIhy8gY3IFIzsgAoD9MhMjekASiHi5moNGFgPBlhMUmQNhi9sJUhafAMRzsajjLD4QZhZ77NJZW4Ue6hQbFbb5eCFYq4AA0YRCGy2EJhhx4zkQ+PhkEWFHUHkw9CUkRoCicGFoiBxdKhtIS6jB/Ehp2yg3gAA9cNh/MhkXwNjQiFRxBNcYhcIhHu5leJNp0VRQ+oqMMg2F0+XqMBhyQADe4Aaw8NBVlo5XlwsHw2CIsBQoSBFH8XS88kG2i8yFowTC+EgABFAXa+Bh8KEBCRyciRrR1dDbOh0cg5mQ3qN7dDxTsChUfWhuCp4NNxAMamVK+TBfDETj0bx8BJyQIk17hqMDVMZuhWZqFFIqKQNOZLABhFjG1X2Rz3FxuaFMVjsZBK10ebjeXz+IIhdD+SDMDboqZZ2l4N0UDlNFrtHFn4IqqJoFa9khlkGHpmC5Wp6j4JglCoVR1G0MJFngfpHgASSwSUikNEgcSg5RYNweCjk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q1ZyjU1y81bUjy3Uo7RAk7ExXqCAqMKA1YnU+A/Uhmw0tA0NTAhwpfGNQqyU+G+0NKiYYUZoH/EnH5YKi+UKlUcKmNSK62cWAK5MgwUckSrMtM86sAWuBkDQImNAGKr7OK8spGaQ11DGAyxSpQZjLTRrS0D8sMrAb+QC3IPw2QFyQq5uOkYq3maVYKDAs8iCSmba+YUWUOygdZfVcifmzhEygmAvIiqwDijhDiJOy0FOovCzPwtAO0I4+vBirFb2CBJ42bJ5T6lASEdQIYKYUMf3UWyABcFCaMOwKgaJGIBTAATmkzYoADYAAOVi2TRxaTAAFjKxnyUPL0ZLMqoFM06gwRdtttxiso6jduhCKyAWLoSBsyVIcoUV23VJQLcq0R0UOwQJAMZqNNUMMqwGi0mFEo5iQToHNPtryI/K4EdKK2dNdrCG9owQ9u4EpkACTCAmT+4Zb+yAX+iCHEe3dFHO/oCzf+4wr5H2y0EBhMp1TO2C3GM0si/BvkZB4vI4WBdxBirgWBEuniK4Kc/ncgegIgY/Bqdq9B6EA2hmRM9g27LW8cnWnMoydsy6iYU26GMQ+GZBBKydNmlKwCKI1GKgVuPgCHAc766EIaY5BGqWPuWWlUNM7WyUIRvMjs3tMUlGqMNGqdIhdU8i+PFEbXMQLM7RrE7hbKDwe4JQQ+wJMmk+ims+6m9yy+wA7y0Apmi7EgHhxtQwAwXaYhYaEicaMs5BGaS6PwNAZOS2modaRydQLaXQMAQweJyKdQdxNqRAdxMKdKWgdxFUZwUIN6eJgAZh7oEAHp7p7oAHYABWEgBTCe2gIerp/pnpoexTBTLpgewYLpqZ4MAQHphTBgHpwYAetYLpyEHaAaSALptAZpnp6THphgWTZptABTQYWgAQWZrp6TfoCevKqZ2gfKwYAQWgaTd51pge6Zoewp2Jkp5cMpipqprWGpv5CcfQIAA -->

<!-- internal state end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=openfga/cli&utm_content=530):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@aaguiarz
Copy link
Member Author

aaguiarz commented Jul 2, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 2, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
README.md (1)

705-705: Fix markdown list style consistency.

The static analysis tool flagged inconsistent list styles. Consider using consistent dash formatting for unordered lists.

-* `--file`: Specifies the file name, `json`, `jsonl`, `yaml` and `csv` files are supported
+- `--file`: Specifies the file name, `json`, `jsonl`, `yaml` and `csv` files are supported
-* `--file`: Specifies the file name, `yaml`, `json`, and `jsonl` files are supported  
+- `--file`: Specifies the file name, `yaml`, `json`, and `jsonl` files are supported

Also applies to: 850-850

internal/tuplefile/read.go (1)

47-75: Well-implemented JSONL parser with good error handling.

The implementation correctly handles the JSONL format (one JSON object per line) and provides informative error messages with line numbers for debugging.

However, there's a minor whitespace linting issue to address:

 	for scanner.Scan() {
 		lineNum++
 		line := strings.TrimSpace(scanner.Text())
+
 		if line == "" {
 			continue
 		}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf8b50b and 39b6997.

📒 Files selected for processing (7)
  • README.md (3 hunks)
  • cmd/tuple/delete_test.go (2 hunks)
  • cmd/tuple/testdata/tuples.jsonl (1 hunks)
  • cmd/tuple/write_test.go (1 hunks)
  • internal/tuplefile/read.go (3 hunks)
  • tests/fixtures/basic-tuples.jsonl (1 hunks)
  • tests/tuple-test-cases.yaml (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/tuplefile/read.go (1)
internal/clierrors/clierrors.go (1)
  • EmptyTuplesFileError (43-45)
🪛 GitHub Actions: Build, Test and Publish
tests/tuple-test-cases.yaml

[error] 1-1: Integration test '001b - it successfully writes tuples to a store using jsonl' failed: Query "successful.0.user" did not match a path.

🪛 markdownlint-cli2 (0.17.2)
README.md

705-705: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


850-850: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🪛 GitHub Check: Lints
internal/tuplefile/read.go

[failure] 54-54:
only one cuddle assignment allowed before if statement (wsl)


[failure] 71-71:
error returned from external package is unwrapped: sig: func github.com/openfga/cli/internal/clierrors.EmptyTuplesFileError(extName string) error (wrapcheck)

🔇 Additional comments (11)
tests/fixtures/basic-tuples.jsonl (1)

1-1: LGTM! Well-formatted JSONL fixture.

The fixture correctly follows JSONL format with a valid tuple containing the required fields (user, relation, object).

tests/tuple-test-cases.yaml (1)

11-16: Confirm JSONL tuple write output structure

The new JSONL test (001b in tests/tuple-test-cases.yaml lines 11–16) is identical to the JSON test but is failing because the path successful.0.user isn’t found when using the JSONL fixture. We need to verify whether the CLI’s JSONL mode truly emits the same JSON structure.

Please run the following locally and compare:

# Capture JSON output
fga tuple write \
  --file=./tests/fixtures/basic-tuples.json \
  --max-tuples-per-write=1 \
  --max-parallel-requests=1 \
  --store-id=$(./tests/scripts/test-data/get-store-id.sh) \
  --model-id=$(./tests/scripts/test-data/get-model-id.sh) \
  > json_output.txt

# Capture JSONL output
fga tuple write \
  --file=./tests/fixtures/basic-tuples.jsonl \
  --max-tuples-per-write=1 \
  --max-parallel-requests=1 \
  --store-id=$(./tests/scripts/test-data/get-store-id.sh) \
  --model-id=$(./tests/scripts/test-data/get-model-id.sh) \
  > jsonl_output.txt

# Compare structures
diff -u json_output.txt jsonl_output.txt | less

Verify that both outputs contain the same wrapper and array under successful so the test’s JSONPath (successful.0.user) will match. If they differ, update either the CLI’s JSONL handling or the test expectations accordingly.

cmd/tuple/testdata/tuples.jsonl (1)

1-3: Excellent test data coverage for JSONL format.

The test data includes good variety: basic tuples and conditional tuples with context. The JSONL format is correctly implemented with one JSON object per line.

cmd/tuple/delete_test.go (2)

123-143: Well-implemented JSONL parsing test.

The test correctly validates JSONL file parsing with expected tuple structure that matches the test data. Good consistency with existing test patterns.


203-207: Appropriate error handling for empty JSONL files.

The error message format is consistent with other file format error handling and properly identifies the JSONL format in the error message.

README.md (3)

705-705: Documentation correctly updated for JSONL support.

The file parameter description now properly includes jsonl format alongside the other supported formats.


754-761: Excellent JSONL format example.

The example clearly demonstrates the JSONL format including both basic tuples and conditional tuples with context. This will help users understand the expected format.


850-850: Consistent documentation for delete command.

The delete command documentation properly includes jsonl format support, maintaining consistency with the write command documentation.

cmd/tuple/write_test.go (1)

151-175: LGTM! Comprehensive test coverage for JSONL parsing.

The test case follows the established pattern and provides good coverage by testing tuples with and without conditions, ensuring the JSONL parser handles various scenarios correctly.

internal/tuplefile/read.go (2)

4-6: Good addition of required imports for JSONL parsing.

The added imports (bufio, bytes, encoding/json) are necessary for the line-by-line JSON parsing implementation.


32-33: LGTM! Consistent integration with existing file format handling.

The new .jsonl case follows the same pattern as other supported formats.

@aaguiarz aaguiarz marked this pull request as ready for review July 7, 2025 20:12
@aaguiarz aaguiarz requested review from a team as code owners July 7, 2025 20:12
@aaguiarz
Copy link
Member Author

aaguiarz commented Jul 7, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 7, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rhamzeh rhamzeh changed the title Add JSONL tuple import support feat: add JSONL tuple import support Jul 7, 2025
@rhamzeh rhamzeh added this pull request to the merge queue Jul 9, 2025
Merged via the queue into main with commit f3bd12d Jul 9, 2025
22 checks passed
@rhamzeh rhamzeh deleted the codex/add-support-for-.jsonl-format-in-fga-tuple-write branch July 9, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants