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]: The object reference was not set to an object instance. #2971

Open
1 task done
luimen6 opened this issue Sep 29, 2024 · 0 comments
Open
1 task done

[BUG]: The object reference was not set to an object instance. #2971

luimen6 opened this issue Sep 29, 2024 · 0 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@luimen6
Copy link

luimen6 commented Sep 29, 2024

What happened?

When I create a new Github client, I get this message: The object reference was not set to an object instance.

Versions

Octokit c# .net 13.0.1

Relevant log output

I created the following code:

private static async Task<Release> GetLatestReleaseVersion()
{
    LogMessage("Erstelle GitHub-Client und prüfe auf Releases...");
    var client = new GitHubClient(new ProductHeaderValue("TestProject"));

    if (!string.IsNullOrEmpty(GithubToken))
    {
        LogMessage("Setze GitHub Token.");
        var tokenAuth = new Credentials(GithubToken);
        client.Credentials = tokenAuth;
    }

    var rateLimit = await client.RateLimit.GetRateLimits();
    LogMessage($"Rate Limit: {rateLimit.Rate.Remaining}/{rateLimit.Rate.Limit}");

    LogMessage("Versuche, alle Releases abzurufen...");
    var releases = await client.Repository.Release.GetAll(GitHubOwner, GitHubRepo);

    if (releases == null || !releases.Any())
    {
        LogMessage("Fehler: Keine Releases gefunden.");
        throw new InvalidOperationException("Keine Releases gefunden.");
    }

    var latestRelease = releases.FirstOrDefault();
    if (latestRelease == null)
    {
        LogMessage("Fehler: Kein Release gefunden.");
        throw new InvalidOperationException("Kein Release gefunden.");
    }

    LogMessage($"Gefundenes Release: {latestRelease.TagName}");
    return latestRelease;
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@luimen6 luimen6 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Sep 29, 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 Oct 7, 2024
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