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

dotnet graphql update throws an Unhandled exception error #6745

Closed
1 task done
Bahri-Haythem opened this issue Dec 4, 2023 · 12 comments · Fixed by #6751
Closed
1 task done

dotnet graphql update throws an Unhandled exception error #6745

Bahri-Haythem opened this issue Dec 4, 2023 · 12 comments · Fixed by #6751

Comments

@Bahri-Haythem
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Product

Strawberry Shake

Describe the bug

When I try to use strawberryshake.tools command dotnet graphql update, I get an Unhandled exception error. The init and download command works fine.

schema.graphql

schema {
  query: Query
}

type Query {
  test: String!
}

// other code removed for brevity

TestQuery.graphql

query Test{
  test
}

The query just returns a simple string: public string Test => "this is a test";

Steps to reproduce

  1. In the console navigate to the project where StrawberryShake is implemented
  2. run dotnet graphql update

Relevant log output

Unhandled exception. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: ?. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.JsonReader.ReadAndMoveToContent()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at StrawberryShake.Tools.Configuration.GraphQLConfig.FromJson(String json) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/Configuration/GraphQLConfig.cs:line 46
   at StrawberryShake.Tools.UpdateCommandHandler.UpdateSingleSchemaAsync(UpdateComman   at StrawberryShake.Tools.UpdateCommandHandler.UpdateSingleSchemaAsync(UpdateComman   at StrawberryShake.Tools.UpdateCommandHandler.UpdateSingleSchemaAsync(UpdateCommandContext context, String clientDirectory, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/UpdateCommandHandler.cs:line 83
   at StrawberryShake.Tools.UpdateCommandHandler.ExecuteAsync(UpdateCommandArguments arguments, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/UpdateCommandHandler.cs:line 46
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at StrawberryShake.Tools.Program.<Main>(String[] args)

Additional Context?

As a workaround I am using init each time to update the schema.graphql file but that changes the .graphqlrc.json each time

Version

13.7.0

@glen-84
Copy link
Collaborator

glen-84 commented Dec 5, 2023

Do you have a reproduction repository?

@glen-84
Copy link
Collaborator

glen-84 commented Dec 5, 2023

Might be caused by a BOM. Try saving the schema files config file as UTF-8 without BOM.

@Bahri-Haythem
Copy link
Author

This is a reproduction repo I made while trying to learn strawberry shake. All the files were generated with the init command I am not supposed to change their encoding.

@glen-84

This comment was marked as outdated.

@kevinoneill
Copy link

kevinoneill commented Dec 6, 2023

I can confirm that removing the bom on the generated .graphqlrc.json resolved the issue for me. Adding the bom back in reproduced the error.

Environment:

ProductName: macOS
ProductVersion: 14.1.1
BuildVersion: 23B81
Dotnet: 8.0.100

@rick-micpoint
Copy link

Ran into this just now as well. If I didn't find this github issue I would have been completely stuck. Probably good to hotfix quickly.

@Bahri-Haythem
Copy link
Author

I confirm the solution done by @kevinoneill .To remove the Bom on linux (or windows with wsl like I did):
sed -i '1s/^\xEF\xBB\xBF//' .graphqlrc.json

@michaelraue
Copy link

Can confirm the problem and the solution by @Bahri-Haythem

@glen-84
Copy link
Collaborator

glen-84 commented Dec 10, 2023

#6751 has been merged, so in the next release, the files will be written without a BOM.

@glen-84 glen-84 linked a pull request Dec 12, 2023 that will close this issue
@glen-84
Copy link
Collaborator

glen-84 commented Dec 12, 2023

Fixed in 13.8.0-preview.1 and 14.0.0-p.16.

@glen-84 glen-84 closed this as completed Dec 12, 2023
@RichardWhitfield
Copy link

I am still having this issue in version 13.9.9

@glen-84
Copy link
Collaborator

glen-84 commented Aug 9, 2024

@RichardWhitfield Please create a minimal reproduction of the issue.

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