NickeManarin/ScreenToGif · warning · Exception
Error while trying to get the latest release: {response.Re
Error message
Error while trying to get the latest release:
{response.ReasonPhrase} What it means
Thrown by GitHubHelper.GetLatestRelease when the GitHub releases API endpoint returns a non-success HTTP status code. The method constructs a URL from the repository parameter and deserializes the JSON into a GitHubRelease object. Any non-2xx response triggers this exception with the HTTP reason phrase.
Source
Thrown at ScreenToGif.Util/GitHubHelper.cs:20
using ScreenToGif.Util.Settings;
using System.Text.Json;
namespace ScreenToGif.Util;
public static class GitHubHelper
{
public static async Task<GitHubRelease> GetLatestRelease(string repository)
{
if (string.IsNullOrWhiteSpace(repository))
throw new ArgumentNullException(nameof(repository));
using var client = WebHelper.GetHttpClient();
client.DefaultRequestHeaders.Add("User-Agent", "ScreenToGif/" + UserSettings.All.VersionText);
using var response = await client.GetAsync($"https://api.github.com/repos/{repository}/releases/latest");
if (!response.IsSuccessStatusCode)
throw new Exception("Error while trying to get the latest release: " + Environment.NewLine + response.ReasonPhrase);
var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<GitHubRelease>(content);
}
public static GitHubAsset GetAsset(this GitHubRelease release, string assetName)
{
if (release is null)
throw new ArgumentNullException(nameof(release));
if (string.IsNullOrWhiteSpace(assetName))
throw new ArgumentNullException(nameof(assetName));
return release.Assets.FirstOrDefault(x => x.Name.Contains(assetName, StringComparison.InvariantCultureIgnoreCase));
}
}View on GitHub (pinned to a4d0a67c21)
Solutions
- Check the response status code and reason phrase — 403 means rate limit, 404 means repo/no-release.
- Cache the last-known release locally and use it when the API is rate-limited.
- Add authentication (GitHub token) to raise the rate limit from 60 to 5000 requests/hour.
- Wrap the call in a try-catch and silently skip update checks on failure rather than crashing.
Example fix
// before
if (!response.IsSuccessStatusCode)
throw new Exception("Error while trying to get the latest release: " + Environment.NewLine + response.ReasonPhrase);
// after: include status code for actionable diagnostics
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"Error while trying to get the latest release: {(int)response.StatusCode} {response.ReasonPhrase}"); Defensive patterns
Strategy: try-catch
Validate before calling
// Check rate limit before calling
var client = WebHelper.GetHttpClient();
client.DefaultRequestHeaders.Add("User-Agent", "ScreenToGif/" + UserSettings.All.VersionText);
var limitResponse = await client.GetAsync("https://api.github.com/rate_limit");
if (limitResponse.IsSuccessStatusCode)
{
var limits = JsonSerializer.Deserialize<JsonDocument>(await limitResponse.Content.ReadAsStringAsync());
var remaining = limits.RootElement.GetProperty("rate").GetProperty("remaining").GetInt32();
if (remaining == 0) return lastCachedRelease;
} Try / catch
try
{
var release = await GitHubHelper.GetLatestRelease(repository);
_cachedRelease = release;
return release;
}
catch (Exception)
{
return _cachedRelease; // use last known good release, or null
} Prevention
- Cache the latest release result so repeated update checks don't re-hit the API.
- Throttle update checks (e.g., once per day, not on every startup) to avoid rate limits.
- Add a GitHub token header to raise the rate limit ceiling when possible.
When it happens
Trigger: GET https://api.github.com/repos/{repository}/releases/latest returns non-2xx. Common status codes: 403 (rate limit exceeded — 60 requests/hour unauthenticated), 404 (repository not found or has no releases), 503 (GitHub server error). The repository parameter may be malformed or the repo renamed.
Common situations: Application checks for updates too frequently, hitting the 60/hour unauthenticated rate limit. Repository was renamed or the owner changed. GitHub API is temporarily down. The 'repository' argument is wrong (e.g., missing owner/repo format). No releases have been published yet (404).
Related errors
- File not found
- Empty response from server when getting language codes
- Empty response from server when getting language codes path
- Unsuccessful download of stream.
- Empty response from server when getting language codes
AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13).
Data as JSON: /api/errors/82579bdf7b537fe8.
Report an issue: GitHub.