{"record":{"id":"bd574a8afdf186b7","repo":"tonhowtf/omniget","slug":"receiver-rejected-transfer-mod","errorCode":null,"errorMessage":"Receiver rejected transfer: {}","messagePattern":"Receiver rejected transfer: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/src/platforms/p2p/mod.rs","lineNumber":299,"sourceCode":"        anyhow::bail!(\"Unexpected relay response: {}\", ready);\n    }\n\n    *session.status.lock().await = \"connected\".to_string();\n    tracing::info!(\"[p2p] receiver connected\");\n\n    let header = format!(\"{}\\n{}\\n\", session.file_name, session.file_size);\n    write_half.write_all(header.as_bytes()).await?;\n    write_half.flush().await?;\n\n    let ok_response = tokio::select! {\n        line = read_line(&mut reader) => line?,\n        _ = cancel.cancelled() => {\n            anyhow::bail!(\"Send cancelled while waiting for OK\");\n        }\n    };\n\n    if ok_response != \"OK\" {\n        anyhow::bail!(\"Receiver rejected transfer: {}\", ok_response);\n    }\n\n    *session.status.lock().await = \"transferring\".to_string();\n    tracing::info!(\n        \"[p2p] transferring: {} ({} bytes)\",\n        session.file_name,\n        session.file_size\n    );\n\n    let mut file = File::open(&session.file_path).await?;\n    let mut buf = vec![0u8; CHUNK_SIZE];\n    let mut sent: u64 = 0;\n\n    loop {\n        if cancel.is_cancelled() {\n            anyhow::bail!(\"Send cancelled during transfer\");\n        }\n","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/platforms/p2p/mod.rs#L281-L317","documentation":"After the header, the receiver must reply exactly \"OK\" to accept the transfer. Any other line (including relay error text that check_relay_error wasn't called on here, \"NO\", or garbage) makes run_sender bail with \"Receiver rejected transfer: {response}\".","triggerScenarios":"Receiver answers the header with a token other than \"OK\" — explicit rejection, receiver-side disk/permission error serialized as a message, or a relay error line forwarded verbatim.","commonSituations":"Receiver declines the prompt, receiver lacks write permission or disk space and its client replies with an error token, or client version mismatch causes the accept token to differ.","solutions":["Read the echoed response in the message — it names why the receiver refused; show it to the user.","On the receiver side, ensure acceptance always writes exactly the line \"OK\\n\".","Check the receiver's disk space and write permissions for its download directory.","Align client versions so the accept/reject tokens match, and consider running check_relay_error on ok_response to separate relay faults from real rejections."],"exampleFix":"// before\nif ok_response != \"OK\" { anyhow::bail!(\"Receiver rejected transfer: {}\", ok_response); }\n// after\ncheck_relay_error(&ok_response)?; // distinguish relay errors from real rejection\nif ok_response != \"OK\" {\n    anyhow::bail!(\"Receiver rejected transfer: {:?}\", ok_response);\n}","handlingStrategy":"try-catch","validationCode":"// receiver-side self-check before accepting\ntokio::fs::write(&out_dir, b\"x\").await?; // ensures disk writable and space available","typeGuard":null,"tryCatchPattern":"match run_sender(session.clone(), cancel.clone()).await {\n    Err(e) if e.to_string().contains(\"Receiver rejected transfer\") => {\n        let reason = extract_after(&e.to_string(), \"transfer: \");\n        ui.show_rejection_reason(reason);\n    }\n    other => other?,\n}","preventionTips":["Receiver must always respond with exactly \"OK\\n\" on accept and a defined REJECT token otherwise.","Check receiver disk space and write permissions before sending the prompt.","Call check_relay_error on the response to separate relay faults from real user rejections.","Keep accept/reject tokens identical across client versions."],"tags":["p2p","protocol","rejected-transfer","receiver"],"backgroundTag":"unexpected-response-shape","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}