emliunix opened a new issue, #5690:
URL: https://github.com/apache/opendal/issues/5690

   ### Describe the bug
   
   Onedrive Chunked upload fails with **invalid request** in 
CreateUploadSession.
   
   Per my test, `@odata.type` should be removed.
   
   And in another [graph API 
doc](https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#request),
 `@odata.type` is not included in the payload.
   
   ### Steps to Reproduce
   
   With opendal onedrive setup, upload a file larger than 4MB.
   ```toml
   [package]
   name = "onedrive_fail"
   version = "0.1.0"
   edition = "2024"
   
   [dependencies]
   anyhow = "1.0.97"
   opendal = { version = "0.52.0", features = ["layers-tracing", 
"services-onedrive"] }
   tokio = { version = "1.43.0", features = ["full", "tracing"] }
   ```
   ```rust
   use std::env;
   
   use opendal::{layers::TracingLayer, services::Onedrive, Builder, 
OperatorBuilder};
   
   #[tokio::main]
   async fn main() -> Result<(), anyhow::Error> {
       let onedrive = Onedrive::default()
           .access_token(env::var("ONEDRIVE_TOKEN")?.as_str());
       let operator = OperatorBuilder::new(onedrive.build()?)
           .layer(TracingLayer{})
           .finish();
       let mut data = Vec::with_capacity(5*1024*1024);  // 5MB
       let dummy: [u8; 16] = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
       for _ in 0..5*1024*1024/16 {
           data.extend_from_slice(&dummy);
       }
       operator.write("/test.data", data).await?;
       Ok(())
   }
   ```
   
   ### Expected Behavior
   
   File successfully uploaded to onedrive.
   
   ### Additional Context
   
   Upload failed with onedrive API returning invalid request. 
   ```
   Error: Unexpected (permanent) at Writer::close, context: { uri: 
https://graph.microsoft.com/v1.0/me/drive/root:/test.data:/createUploadSession, 
response: Parts { status: 400, version: HTTP/1.1, headers: {"cache-control": 
"no-store, no-cache, max-age=0, private", "transfer-encoding": "chunked", 
"content-type": "application/json", "strict-transport-security": 
"max-age=31536000", "request-id": "3a0b3c14-41fd-4a39-8b94-924a521248d1", 
"client-request-id": "3a0b3c14-41fd-4a39-8b94-924a521248d1", 
"x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"Korea 
Central\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"SE1PEPF00000820\"}}",
 "date": "Mon, 03 Mar 2025 16:41:53 GMT"} }, service: onedrive, path: 
test.data, written: 5242880 } => 
{"error":{"code":"invalidRequest","message":"Invalid 
request","innerError":{"date":"2025-03-03T16:41:54","request-id":"3a0b3c14-41fd-4a39-8b94-924a521248d1","client-request-id":"3a0b3c14-41fd-4a39-8b94-924a521248d1"}}}
   ```
   
   ### Are you willing to submit a PR to fix this bug?
   
   - [x] Yes, I would like to submit a PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to