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: Incorrect error handling #2601

Closed
JC-comp opened this issue Jan 21, 2024 · 3 comments
Closed

Bug: Incorrect error handling #2601

JC-comp opened this issue Jan 21, 2024 · 3 comments
Labels
Bug Something isn't working Fixed
Milestone

Comments

@JC-comp
Copy link
Contributor

JC-comp commented Jan 21, 2024

Describe the bug

Multiple functions handle errors incorrectly that do not return after retrying the function. As a result, the validation check fails when returning from the recovering retry in the original failed case, even though the operation is actually successful.

Here is one of the affected functions that should return after the retry function is called; otherwise, it will fail the validation after returning (the last line in the follow code).

onedrive/src/sync.d

Lines 4555 to 4595 in e92947e

if ((exception.httpStatusCode == 408) || (exception.httpStatusCode == 429) || (exception.httpStatusCode == 503) || (exception.httpStatusCode == 504)) {
// Handle the 429
if (exception.httpStatusCode == 429) {
// HTTP request returned status code 429 (Too Many Requests). We need to leverage the response Retry-After HTTP header to ensure minimum delay until the throttle is removed.
handleOneDriveThrottleRequest(createDirectoryOnlineOneDriveApiInstance);
addLogEntry("Retrying original request that generated the OneDrive HTTP 429 Response Code (Too Many Requests) - attempting to retry " ~ thisFunctionName, ["debug"]);
}
// re-try the specific changes queries
if ((exception.httpStatusCode == 408) || (exception.httpStatusCode == 503) || (exception.httpStatusCode == 504)) {
// 408 - Request Time Out
// 503 - Service Unavailable
// 504 - Gateway Timeout
// Transient error - try again in 30 seconds
auto errorArray = splitLines(exception.msg);
addLogEntry(to!string(errorArray[0]) ~ " when attempting to create a remote directory on OneDrive - retrying applicable request in 30 seconds");
addLogEntry(thisFunctionName ~ " previously threw an error - retrying", ["debug"]);
// The server, while acting as a proxy, did not receive a timely response from the upstream server it needed to access in attempting to complete the request.
addLogEntry("Thread sleeping for 30 seconds as the server did not receive a timely response from the upstream server it needed to access in attempting to complete the request", ["debug"]);
Thread.sleep(dur!"seconds"(30));
}
// re-try original request - retried for 429, 503, 504 - but loop back calling this function
addLogEntry("Retrying Function: " ~ thisFunctionName, ["debug"]);
createDirectoryOnline(thisNewPathToCreate);
} else {
// If we get a 400 error, there is an issue creating this folder on Microsoft OneDrive for some reason
// If the error is not 400, re-try, else fail
if (exception.httpStatusCode != 400) {
// Attempt a re-try
createDirectoryOnline(thisNewPathToCreate);
} else {
// We cant create this directory online
addLogEntry("This folder cannot be created online: " ~ buildNormalizedPath(absolutePath(thisNewPathToCreate)), ["debug"]);
}
}
}
}
// If we get to this point - onlinePathData = createDirectoryOnlineOneDriveApiInstance.getPathDetailsByDriveId(parentItem.driveId, thisNewPathToCreate) generated a 'valid' response ....
// This means that the folder potentially exists online .. which is odd .. as it should not have existed
if (onlinePathData.type() == JSONType.object) {

[2024-Jan-21 19:25:51.6362107] OneDrive Client requested to create this directory online: ./some_directory
[2024-Jan-21 19:25:51.8854316] HTTP request returned status code 503 (Service Unavailable) when attempting to create a remote directory on OneDrive - retrying applicable request in 30 seconds
[2024-Jan-21 19:26:21.8856349] OneDrive Client requested to create this directory online: ./some_directory
[2024-Jan-21 19:26:22.2312987] ERROR: There was an error performing this operation on Microsoft OneDrive
[2024-Jan-21 19:26:22.2313102] ERROR: Increase logging verbosity to assist determining why.
[2024-Jan-21 19:26:22.2313248] Skipping: /home/alan/OneDrive/some_directory

Operating System Details

Linux JC 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Client Installation Method

From Source

OneDrive Account Type

Personal

What is your OneDrive Application Version

v2.5.0-alpha-5 GitHub version: v2.4.25-47-ge92947e

What is your OneDrive Application Configuration

Reading configuration file: /home/alan/.config/onedrive/config
Invalid value for key in config file - using default value: monitor_fullscan_frequency
Configuration file successfully loaded
onedrive version                             = v2.5.0-alpha-5 GitHub version: v2.4.25-47-ge92947e
Config path                                  = /home/alan/.config/onedrive
Config file found in config path             = true
Config option 'drive_id'                     =
Config option 'sync_dir'                     = ~/OneDrive
Config option 'enable_logging'               = true
Config option 'log_dir'                      = /var/log/onedrive
Config option 'disable_notifications'        = false
Config option 'skip_dir'                     = node_modules|.next
Config option 'skip_dir_strict_match'        = false
Config option 'skip_file'                    = ~*|.~*|*.tmp|*.swp|*.partial|mailboxes.lock*|.lock|node_modules|.next|desktop.ini
Config option 'skip_dotfiles'                = false
Config option 'skip_symlinks'                = false
Config option 'monitor_interval'             = 86400
Config option 'monitor_log_frequency'        = 0
Config option 'monitor_fullscan_frequency'   = 12
Config option 'read_only_auth_scope'         = false
Config option 'dry_run'                      = false
Config option 'upload_only'                  = false
Config option 'download_only'                = false
Config option 'local_first'                  = true
Config option 'check_nosync'                 = false
Config option 'check_nomount'                = false
Config option 'resync'                       = false
Config option 'resync_auth'                  = false
Config option 'cleanup_local_files'          = false
Config option 'classify_as_big_delete'       = 0
Config option 'disable_upload_validation'    = false
Config option 'disable_download_validation'  = false
Config option 'bypass_data_preservation'     = false
Config option 'no_remote_delete'             = false
Config option 'remove_source_files'          = false
Config option 'sync_dir_permissions'         = 700
Config option 'sync_file_permissions'        = 600
Config option 'space_reservation'            = 52428800
Config option 'application_id'               = d50ca740-c83f-4d1b-b616-12c519384f0c
Config option 'azure_ad_endpoint'            =
Config option 'azure_tenant_id'              =
Config option 'user_agent'                   = ISV|abraunegg|OneDrive Client for Linux/v2.5.0-alpha-5
Config option 'force_http_11'                = false
Config option 'debug_https'                  = false
Config option 'rate_limit'                   = 0
Config option 'operation_timeout'            = 3600
Config option 'dns_timeout'                  = 60
Config option 'connect_timeout'              = 10
Config option 'data_timeout'                 = 240
Config option 'ip_protocol_version'          = 0
Config option 'threads'                      = 8

Selective sync 'sync_list' configured        = true
sync_list config option 'sync_root_files'    = false
sync_list contents:
/alan/

Config option 'sync_business_shared_items'   = false
Selective Business Shared Items configured   = false

Config option 'webhook_enabled'              = false

What is your 'curl' version

Skipped

Where is your 'sync_dir' located

Local

What are all your system 'mount points'

Skipped

What are all your local file system partition types

Skipped

How do you use 'onedrive'

Skipped

Steps to reproduce the behaviour

Skipped

Complete Verbose Log Output

Skipped

Screenshots

No response

Other Log Information or Details

No response

Additional context

No response

@JC-comp JC-comp added the Bug Something isn't working label Jan 21, 2024
@abraunegg
Copy link
Owner

abraunegg commented Jan 21, 2024

@JC-comp
Fixing this correctly is where your PR #2608 comes into play to refactor the API.

I am going to put this Issue on hold until this refactor can be looked at and integrated, then, go back and look at this more closely.

@abraunegg
Copy link
Owner

Fixed in #2686

@abraunegg
Copy link
Owner

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Repository owner locked as resolved and limited conversation to collaborators May 2, 2024
@abraunegg abraunegg modified the milestones: v2.5.x, v2.5.0 Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Fixed
Projects
None yet
Development

No branches or pull requests

2 participants