-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
FILE_MIGRATE_ errors not handled for file downloads
Problem
Downloading ChatPhotoInfo.Small files for personal photos (photos set by the current user for a contact) permanently fails with FILE_MIGRATE_1 (HTTP 303). The photo is stored on DC 1 but TDLib tries to download from DC 3 and never retries on the correct DC.
Root Cause
NetQueryDispatcher::try_fix_migrate() (td/telegram/net/NetQueryDispatcher.cpp:390-406) handles 303 errors, but only for three prefixes:
static constexpr CSlice prefixes[] = {"PHONE_MIGRATE_", "NETWORK_MIGRATE_", "USER_MIGRATE_"};
FILE_MIGRATE_ is not in this list. So when a file download query returns 303 / FILE_MIGRATE_1:
NetQueryDispatcher::dispatch()(line 96-97) sees code 303, callstry_fix_migrate()try_fix_migrate()doesn't matchFILE_MIGRATE_, does nothing, returns- The error propagates to
FileManager::on_download_error_impl()(line 4913) on_download_error_impl()has no handler for it either (lines 4918-4961 handleFILE_ID_INVALID, file reference errors,FILE_DOWNLOAD_RESTART,MTPROTO_CLUSTER_INVALID— but notFILE_MIGRATE)- The error is logged at line 4972 and converted to a 400 error at line 4988
on_file_load_error()(line 4991) cancels the download permanently
Reproduction
- Set a personal photo for a contact (via "Set Photo for This Contact")
- The ChatPhotoInfo.Small file for that contact will have a DC ID that may differ from the DC where the file is actually stored
- TDLib will attempt to download from the stored DC, receive FILE_MIGRATE_N, and fail permanently
- The contact's profile picture will only ever show the blurry minithumbnail
Evidence from logs
[Session:3:download_small#0] Receive error [...] [Error : 303 : FILE_MIGRATE_1]
Failed to Download file 4385(0) of type ChatPhoto: [Error : 303 : FILE_MIGRATE_1]
Failed to Download file 4377(0) of type ChatPhoto: [Error : 303 : FILE_MIGRATE_1]
Key files and lines
td/telegram/net/NetQueryDispatcher.cpplines 390-406:try_fix_migrate()— missingFILE_MIGRATE_prefixtd/telegram/net/NetQueryDispatcher.cpplines 96-97: 303 error dispatch callstry_fix_migrate()td/telegram/files/FileManager.cpplines 4918-4961:on_download_error_impl()— noFILE_MIGRATEhandlertd/telegram/files/FileManager.cpplines 4972-4973: Error logged as warning, then treated as fatal
Possible fix
Add FILE_MIGRATE_ handling in try_fix_migrate(), but without changing the main DC (unlike the other migrate errors, this just means resend the query to a different DC):
// In try_fix_migrate(), before the existing prefix loop:
static constexpr CSlice file_migrate_prefix = "FILE_MIGRATE_";
if (begins_with(error_message, file_migrate_prefix)) {
auto new_dc_id = to_integer<int32>(error_message.substr(file_migrate_prefix.size()));
if (DcId::is_valid(new_dc_id)) {
net_query->resend(DcId::internal(new_dc_id));
}
return;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels