Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve crash in TransformModuleFilesToModel if regular schema file passed instead #386

Merged
merged 2 commits into from
Nov 23, 2024

Conversation

fsedano
Copy link
Contributor

@fsedano fsedano commented Nov 20, 2024

Description

The change checks the metadata for the module, if it's null it returns the proper error.

References

Fixes #384

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@fsedano fsedano requested review from a team as code owners November 20, 2024 14:02
@fsedano
Copy link
Contributor Author

fsedano commented Nov 21, 2024

@elbuo8 - Hi, would it be possible to have a review on this? It's impacting our production code and I rather not deploy a patched version, so would love having this fixed upstream. Thanks!

@rhamzeh
Copy link
Member

rhamzeh commented Nov 21, 2024

@fsedano - do you require an error? What do you think about returning a transformation with the module name empty?

In general OpenFGA treats type defs with module name as an empty string as having no module attached

What if we validate that if there is metadata set, the schema version is the same as the one passed in? So if you are passing in 1.2 and in the file it states 1.1 we can error on that?

@rhamzeh rhamzeh changed the title If a regular schema file, instead of a module, was passed to TransformModuleFilesToModel, it would crash. fix(go): resolve crash in TransformModuleFilesToModel if regular schema file passed instead Nov 21, 2024
@fsedano
Copy link
Contributor Author

fsedano commented Nov 21, 2024

@rhamzeh In general I'd prefer to have an error, since this is most probably a input error. If the user wants to accept both it could catch the error and use the regular API for that. If we just hide the error it will go unnoticed and it might have unexpected side effects.

The way this was caught in prod is because somebody by mistake commited the wrong file as a module. I rather error out to point the user about the mistake.

@rhamzeh
Copy link
Member

rhamzeh commented Nov 22, 2024

@rhamzeh In general I'd prefer to have an error, since this is most probably a input error. If the user wants to accept both it could catch the error and use the regular API for that. If we just hide the error it will go unnoticed and it might have unexpected side effects.

The way this was caught in prod is because somebody by mistake commited the wrong file as a module. I rather error out to point the user about the mistake.

Thanks for elaborating, will approve this to unblock you, and in the future we'll add options to allow this use-case.

May I ask if you can also add the JS fix so that this passes the tests and we can merge?

The one I currently forsee is allowing folks to run and test and transform their module without worrying about the module file and then a separate platform process does the combining - but as that is not a current use-case, it shouldn't be a blocker.

Also can I ask how are you consuming this? Is it by calling it directly or through the CLI? (to see if we need to spin up a new CLI release that contains this fix to unblock you)

rhamzeh
rhamzeh previously approved these changes Nov 22, 2024
@fsedano
Copy link
Contributor Author

fsedano commented Nov 23, 2024

Thanks @rhamzeh - Just fixed also the JS one, thanks for letting me know.
We are not using CLI, but the Go SDK, so no CLI hotfix is needed.

Thanks again!

@rhamzeh rhamzeh changed the title fix(go): resolve crash in TransformModuleFilesToModel if regular schema file passed instead fix: resolve crash in TransformModuleFilesToModel if regular schema file passed instead Nov 23, 2024
@fsedano
Copy link
Contributor Author

fsedano commented Nov 23, 2024

Thanks @rhamzeh - Is there anything else I have to do to have this merged or will it happen automagically? Thanks,

@rhamzeh rhamzeh added this pull request to the merge queue Nov 23, 2024
Merged via the queue into openfga:main with commit 1ed66e7 Nov 23, 2024
18 checks passed
@rhamzeh
Copy link
Member

rhamzeh commented Nov 23, 2024

Was waiting for all the tests to pass, just added it to the queue.

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash if a model is sent to TransformModuleFilesToModel
2 participants