hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.13k stars 2.76k forks source link

Permissions on remote schema enum causing parsing errors #7572

Open aaka3207 opened 3 years ago

aaka3207 commented 3 years ago

Version Information

Server Version: v2.0.8 CLI Version (for CLI related issue): v2.0.3

Environment

What is the expected behaviour?

When my remote schemas contains enums and I need to apply permissions to them, the standard format without newlines should apply, or the engine should properly parse out newlines

Keywords

What is the current behaviour?

One of my remote schemas contains an enum of strings, and I have custom permissions for different users on accessing these fields. However, having enums causes the console to use line breaks between the strings, and the next time I start the engine I receive a remote schema parsing error.

My workaround has been to remove all lines breaks from the metadata and make the entire permission one line. However, if I modify one permission or sometimes modify another permission in the console. it will cause the metadata to restore the default format with the newlines, and I have to keep repeating the cycle.

I can confirm that when I delete the enum fields from my remote schema and reload the metadata, the console creates a format without newlines that is recognized by the engine.

I feel like this is a very easy fix but I don't know Haskell 😅.

I'm using TypeGraphQL to make my remote schemas.

How to reproduce the issue?

  1. Create a remote schema with enum string fields.
  2. From the console, apply remote schema permissions to all fields including the enum
  3. Restart the engine, or apply metadata again.

Workarounds:

  1. Remove all newlines from remote schema permission and format the entire string into one line
  2. Remove enum fields, apply new permissions and reload metadata.

Screenshots or Screencast

Remote schema metadata with newlines

image

Please provide any traces or logs that could help here.

Stack trace when starting engine (using hasura/graphql-engine:v2.0.8.cli-migrations-v3)

time="2021-09-17T16:25:22Z" level=fatal msg="error applying metadata \n{\n \"path\": \"$.args.metadata.remote_schemas[1].permissions[1].definition.schema\",\n \"error\": \"parsing the schema document: \\\"endOfInput\\\"\",\n \"code\": \"parse-failed\"\n}"

Any possible solutions?

Can you identify the location in the source code where the problem exists?

If the bug is confirmed, would you be willing to submit a PR?

dulara1994 commented 3 years ago

I also faced the same issue with remote schemas. is there anything we can do to bypass the issue?

aaka3207 commented 3 years ago

Almost a month and I still haven't received any response on this, and it's still breaking for me.

BenoitRanque commented 3 years ago

Related to #7459