G
YouTube TikTok Games
Skip to content

store import should import tests as assertions #398

Open

Description

@aaguiarz

If the .fga.yaml file contains tests, those should be imported as assertions.

I think this used to work, but it's currently not working.

Activity

  1. Corgam commented on Jan 10, 2025

    @Corgam

    For me, the tuples defined in the .fga.yaml file are not imported correctly either.

  2. ahmedashraffcih commented on Sep 24, 2026

    @ahmedashraffcih

    I took a look at this and I don't think it reproduces on current main any more — it looks like it was fixed by #446 and the issue was just never closed.

    #446 ("support importing assertions as part of a store") landed on 2025-02-07 and added importAssertions in cmd/store/import.go, which converts each test's check entries into client.ClientAssertion values and calls WriteAssertions. This issue was filed 2024-09-25 and @Corgam's comment is from 2025-01-10, so both predate that change. #446's description says it closes #224, which is probably why this one stayed open.

    I verified end-to-end against main (d4469b1) rather than just reading the code:

    1. Started openfga/openfga:latest and built the CLI from main.
    2. Ran fga store import on the repo's own tests/fixtures/basic-store.fga.yaml, which uses model_file, tuple_file and a tests[].check block with assertions: {owner: true}.
    3. Read the results back from the server.

    GET /stores/{store_id}/assertions/{model_id} returned:

    {"assertions":[{"tuple_key":{"object":"group:foo","relation":"owner","user":"user:anne"},"expectation":true,"contextual_tuples":[],"context":null}]}

    So the test was imported as an assertion as expected.

    On @Corgam's follow-up about tuples — those import correctly too. The same run's POST /stores/{store_id}/read returned the tuple from tuple_file:

    {"tuples":[{"key":{"user":"user:anne","relation":"owner","object":"group:foo","condition":null}}]}

    LoadTuples in internal/storetest/storedata.go merges tuples, tuple_file and tuple_files, and resolves each test's own tuple_file, so I couldn't find a path where they're dropped.

    One thing worth noting in case it's what was originally meant: importAssertions only converts check entries. list_objects and list_users tests are skipped, because WriteAssertions only models check-style assertions server-side. That's an API limitation rather than a bug, but if the intent was for those to become assertions too, that'd be a separate feature request.

    Happy to open a PR adding an integration-test case that asserts the imported assertions actually reach the server if that'd be useful — the current fixtures in tests/import-tests-cases.yaml only check the command's stdout and exit code, so there's no regression guard on this specific behaviour. Otherwise I think this can be closed.

    @Corgam — if you're still seeing this on a recent version, a repro .fga.yaml and your CLI version would help.

  3. Corgam commented on Sep 24, 2026

    @Corgam

    Unfortunately, I do not work on this anymore, neither I have the old code. So I cannot help, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions