NickeManarin/ScreenToGif · error · UploadException
{errorDescriptor.Error}, {errorDescriptor.Message}, {errorDe
Error message
{errorDescriptor.Error}, {errorDescriptor.Message}, {errorDescriptor.Description} What it means
Inside GetAsync<T>, the response body is first deserialized as an ErrorDescriptor; if its Error field is non-null, UploadException is thrown carrying the Yandex-provided error/message/description triple verbatim. This is the user-facing passthrough of any Yandex Disk REST API failure.
Source
Thrown at ScreenToGif/Cloud/YandexDisk.cs:78
{
var request = new HttpRequestMessage(HttpMethod.Get, url)
{
Headers =
{
{HttpRequestHeader.Authorization.ToString(), "OAuth " + preset.OAuthToken}
}
};
string responseBody;
using (var response = await client.SendAsync(request, cancellationToken))
{
responseBody = await response.Content.ReadAsStringAsync(cancellationToken);
}
var errorDescriptor = Serializer.Deserialize<ErrorDescriptor>(responseBody);
if (errorDescriptor.Error != null)
throw new UploadException($"{errorDescriptor.Error}, {errorDescriptor.Message}, {errorDescriptor.Description}");
return Serializer.Deserialize<T>(responseBody);
}
}
private async Task PutAsync(YandexPreset preset, string url, HttpContent content, CancellationToken cancellationToken)
{
var handler = new HttpClientHandler
{
Proxy = WebHelper.GetProxy(),
PreAuthenticate = true,
UseDefaultCredentials = false,
};
using (var client = new HttpClient(handler))
{
var request = new HttpRequestMessage(HttpMethod.Put, url)
{View on GitHub (pinned to a4d0a67c21)
Solutions
- Re-authorize Yandex if the message indicates unauthorized/invalid token.
- Free up Yandex Disk space if the message indicates DiskFull / quota exceeded.
- Surface the triple (error, message, description) directly to the user rather than the generic label.
- Add an HttpStatusCode check on response.StatusCode before deserializing, so non-200 responses are handled explicitly.
Example fix
// before
if (errorDescriptor.Error != null)
throw new UploadException($"{errorDescriptor.Error}, {errorDescriptor.Message}, {errorDescriptor.Description}");
// after
if ((int)response.StatusCode >= 400 || errorDescriptor.Error != null)
throw new UploadException($"Yandex {errorDescriptor.Error ?? response.StatusCode.ToString()}: {errorDescriptor.Message}. {errorDescriptor.Description}"); Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: token must be present and quota assumed available var yp = preset as YandexPreset; if (string.IsNullOrWhiteSpace(yp?.OAuthToken)) /* prompt re-auth */
Type guard
// n/a — error is data-driven, not type-driven
Try / catch
try { return await cloud.UploadFileAsync(preset, path, token); }
catch (UploadException ex) when (ex.Message.Contains("unauthorized") || ex.Message.Contains("UnauthorizedError"))
{ /* refresh OAuth token, retry once */ }
catch (UploadException ex) when (ex.Message.Contains("DiskFull"))
{ /* surface quota message to user */ } Prevention
- Check HTTP status code explicitly in GetAsync instead of relying solely on the body's error field.
- Surface the Yandex error triple verbatim to the user.
- Refresh the OAuth token on a schedule to avoid unauthorized errors.
When it happens
Trigger: Any Yandex cloud-api.yandex.net response containing a JSON 'error' field: 401 unauthorized (bad OAuth token), 406 invalid field, 413 file too large, 507 disk full, rate limiting, or ' DiskResourcePathNotFoundError'. The HTTP status itself is not checked — only the body's error field.
Common situations: Expired or revoked OAuth token; Yandex Disk quota exceeded (507 disk full); upload path collisions or forbidden characters; rate-limit response; region/network returned a Yandex-formatted error JSON.
Related errors
- Unknown error
- It was not possible to get the authorization to upload to Im
- history.Message
- File not found
- Can't get language codes. Path to language codes is null
AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13).
Data as JSON: /api/errors/87f4e7e9506903ae.
Report an issue: GitHub.