hasura / hasura/graphql-engine

Permissions on remote schema enum causing parsing errors

Open
#7,572 3 comments 1 reaction 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### 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](https://user-images.githubusercontent.com/16450271/133821803-0bc4aa8b-81de-4e24-a8cb-f12518019f43.png)

### 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?

Contributor guide

Open the contributing guide

Research direction

Start with the metadata.remote_schemas permissions definition.schema path and reproduce the issue using enum fields, console permissions, and a metadata reload or engine restart. Trace the schema-document parser for the reported endOfInput error; done means console-generated permissions containing newlines are accepted without requiring manual reformatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, typescript
Domain
api, authorization, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.