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

Better errors for schema module validation failures #279

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

grantwest
Copy link
Contributor

@grantwest grantwest commented Feb 28, 2023

Addresses 2 schema module validation issues:

Use Code.ensure_compiled!/1 rather than Code.ensure_compiled/1 to avoid masking compile issues and avoid potential race conditions. The existing pattern is specifically warned against in the elixir docs: https://hexdocs.pm/elixir/1.14/Code.html#module-code-loading-on-the-erlang-vm

With the current code it is possible to get theis not valid Absinthe.Schema error even though the issue is actually a failure to compile another module. This creates a painful experience.

The second improvement is to specify exactly why a schema has failed validation. If a validation fails, the next question asked is why? This change answers that question immediately, rather than making the user change absinthe_plug code to debug.

Because Code.ensure_compiled!/1 is introduced in elixir 1.12 this commit also bumps the minimum elixir version up to 1.12.

@grantwest grantwest force-pushed the better-errors-for-schema-validation branch 2 times, most recently from da9d1e2 to e1f81bf Compare March 1, 2023 13:41
@grantwest
Copy link
Contributor Author

It looks like Code.ensure_compiled!/1 was added in elixir 1.12.0. Are you open to bumping the minimum elixir version up to 1.12.0 for the next release? If so, do you want a separate PR or should I do it in this one?

@benwilson512
Copy link
Contributor

I am open to bumping the Elixir requirement to 1.12.0

Addresses 2 schema module validation issues:

Use `Code.ensure_compiled!/1` rather than `Code.ensure_compiled/1` to
avoid masking compliation issues and avoid potential race conditions.
The existing pattern is specifically warned against in the elixir
docs: https://hexdocs.pm/elixir/1.14/Code.html#module-code-loading-on-the-erlang-vm

With the current code it is possible to get the
`is not valid Absinthe.Schema` even though the issue is actually a
failure to compile another module. This creates a painful experience.

The second improvement is to specify exactly why a schema has failed
validation. If a validation fails, the next question asked is why? This
change answers that question immediately, rather than making the user
change absinthe_plug code to debug.

Because `Code.ensure_compiled!/1` is introduced in elixir 1.12 this
commit also bumps the minimum elixir version up to 1.12.
@grantwest grantwest force-pushed the better-errors-for-schema-validation branch from e1f81bf to 88644c6 Compare March 1, 2023 14:37
@grantwest
Copy link
Contributor Author

Ok, I bumped the min elixir version in this same commit to maintain the reason for the bump in the commit history.

To avoid an error compling telemetry 0.4.2 on elixir 1.12.0 w/ otp 22.3
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.

None yet

2 participants