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

[BUG]: System.NullReferenceException in Repository.GetAllLanguages() #2947

Open
1 task done
anrouxel opened this issue Jul 2, 2024 · 4 comments
Open
1 task done
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@anrouxel
Copy link

anrouxel commented Jul 2, 2024

What happened?

When calling Repository.GetAllLanguages() on anrouxel/MedicApp. I'm getting a System.NullReferenceException: Object reference not set to an instance of an object.

Versions

Octokit.Reactive : 13.0.0

Relevant log output

System.NullReferenceException: Object reference not set to an instance of an object. blazor.webassembly.js:1:46936
   at Octokit.PocoJsonSerializerStrategy.DeserializeObject(Object value, Type type) in /_/Octokit/SimpleJson.cs:line 1486 blazor.webassembly.js:1:46936
   at Octokit.Internal.SimpleJsonSerializer.GitHubSerializerStrategy.DeserializeObject(Object value, Type type) in /_/Octokit/Http/SimpleJsonSerializer.cs:line 205 blazor.webassembly.js:1:46936
   at Octokit.PocoJsonSerializerStrategy.DeserializeObject(Object value, Type type) in /_/Octokit/SimpleJson.cs:line 1519 blazor.webassembly.js:1:46936
   at Octokit.Internal.SimpleJsonSerializer.GitHubSerializerStrategy.DeserializeObject(Object value, Type type) in /_/Octokit/Http/SimpleJsonSerializer.cs:line 205 blazor.webassembly.js:1:46936
   at Octokit.SimpleJson.DeserializeObject(String json, Type type, IJsonSerializerStrategy jsonSerializerStrategy) in /_/Octokit/SimpleJson.cs:line 584 blazor.webassembly.js:1:46936
   at Octokit.SimpleJson.DeserializeObject[List`1](String json, IJsonSerializerStrategy jsonSerializerStrategy) in /_/Octokit/SimpleJson.cs:line 596 blazor.webassembly.js:1:46936
   at Octokit.Internal.SimpleJsonSerializer.Deserialize[List`1](String json) in /_/Octokit/Http/SimpleJsonSerializer.cs:line 22 blazor.webassembly.js:1:46936
   at Octokit.Internal.JsonHttpPipeline.DeserializeResponse[List`1](IResponse response) in /_/Octokit/Http/JsonHttpPipeline.cs:line 62 blazor.webassembly.js:1:46936
   at Octokit.Connection.<Run>d__69`1[[System.Collections.Generic.List`1[[System.Tuple`2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int64, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() in /_/Octokit/Http/Connection.cs:line 784

Code of Conduct

  • I agree to follow this project's Code of Conduct
@anrouxel anrouxel added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jul 2, 2024
@anrouxel anrouxel changed the title [BUG]: [BUG]: System.NullReferenceException: Object reference not set to an instance of an object Jul 2, 2024
@anrouxel anrouxel changed the title [BUG]: System.NullReferenceException: Object reference not set to an instance of an object [BUG]: System.NullReferenceException in Repository.GetAllLanguages() Jul 2, 2024
@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Jul 2, 2024
@kfcampbell
Copy link
Member

Are you actually calling Repository.GetAllLanguages() without giving any arguments for the repository? I'm unable to reproduce this with the following code on the latest main branch release:

var client = new GitHubClient(new ProductHeaderValue("MyApp"));
var languages = await client.Repository.GetAllLanguages("octokit", "octokit.net");
foreach (var language in languages)
{
  Console.WriteLine($"{language.Name}: {language.NumberOfBytes}");
}

This prints the following:

C#: 10195466
PowerShell: 8539
Dockerfile: 637
Shell: 442

@anrouxel
Copy link
Author

anrouxel commented Jul 2, 2024

Hi @kfcampbell ,
I use Octokit.Reactive and not Octokit.

using Octokit;
using Octokit.Reactive;

class Program
{
    static string owner = "anrouxel";
    static string name = "MedicApp";

    static ObservableGitHubClient client = new ObservableGitHubClient(new ProductHeaderValue("ophion"));

    static void Main(string[] args)
    {
        // fetch all open pull requests
        client.Repository.GetAllLanguages(owner, name)
            .Subscribe(data =>
                {
                    Console.WriteLine("Language: ", data.Name);
                },
                ex =>
                {
                    Console.WriteLine("Exception found: " + ex.ToString());
                });

        // this will take a while, let's wait for user input before exiting
        Console.ReadLine();
    }
}

@kfcampbell
Copy link
Member

Can you please reduce the snippet to something similar to what I gave above? As presented, it's not runnable for me.

@anrouxel
Copy link
Author

anrouxel commented Jul 2, 2024

I've reduced the snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

2 participants