Microsoft Graph OneDrive Personal: can a final upload complete after session cancellation?

Felipe Afonso 0 Reputation points
2026-11-19T00:43:44.4133333+00:00

Hello Microsoft Graph team,

I am developing an application that uploads files to OneDrive Personal using Microsoft Graph v1.0 and createUploadSession.

I need clarification about a race condition:

  1. A client starts the final PUT request to an upload session.
  2. Before the client receives the PUT response, another process sends DELETE to the same upload session URL.
  3. The DELETE request returns HTTP 204 No Content.
  4. A subsequent lookup of the destination file returns HTTP 404 Not Found.

Does Microsoft guarantee that the final PUT, if it was already received or being processed, cannot create the file after the DELETE response?

Does the subsequent 404 guarantee that the file will not appear later as a result of that PUT? If not, is there a documented way to establish that the upload can no longer complete?

Please clarify the guarantees specifically for OneDrive Personal and Microsoft Graph v1.0, including cases where a response is lost or a request times out. A link to the relevant official documentation would be appreciated.

Thank you.

Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Oldest
  1. AI answer

    2026-11-19T00:44:41.2133333+00:00

    Microsoft does not document a OneDrive Personal guarantee that a 204 No Content from DELETE prevents an already concurrent final PUT from committing, nor that a destination-item 404 Not Found proves the item cannot appear afterward.

    What the documented responses establish

    • With deferCommit omitted or false, receiving the final byte range automatically completes the upload. A successful final PUT returns 200 OK or 201 Created and the completed driveItem metadata. ^1^
    • DELETE uploadUrl cancels the session and cleans up the temporary file; its documented success response is 204 No Content. The documentation does not define serialization or precedence between that DELETE and a final PUT already being processed. ^1^
    • A 404 from the upload-session URL means that the upload session no longer exists, and the documented recovery is to start the upload again. That is different from a 404 when looking up the destination path: the latter only reports that no matching item was returned by that lookup. ^1^
    • If an upload request disconnects or fails before the request is completed, all bytes from that request are ignored. This does not cover a request that the service completed when only its response was lost. ^1^

    Consequently, neither the DELETE 204 nor an immediately following destination 404 is a documented proof that the racing final PUT cannot subsequently be observed as committed.

    Handling a lost or timed-out final response

    Treat the result as ambiguous rather than automatically retrying the entire upload:

    1. Query the upload URL with GET.
      • 200 OK with nextExpectedRanges means the session still exists and identifies missing data.
      • 404 Not Found means the session no longer exists. It does not distinguish, by itself, between cancellation and prior successful completion.
    2. Look up the destination item and validate its identity. Do not rely only on the path existing. Compare the returned item ID and relevant properties such as name and size with the intended upload.
    3. If neither request establishes success, record an indeterminate outcome. The published v1.0 contract provides no transaction-status or cancellation-fence operation that proves the final PUT lost the race.
    4. Avoid blindly replaying the full operation under replace or rename. Depending on conflict behavior, that can overwrite an item or create another item rather than resolve whether the first operation committed.

    Microsoft recommends retrying interrupted uploads and 5xx responses, using exponential backoff for 5xx errors. That retry guidance does not make a timed-out final commit exactly-once. ^1^

    Reduce the race with deferCommit

    For new sessions, set deferCommit to true. Uploading the final byte then does not create the destination file until an explicit completion request is made:

    POST /me/drive/items/{parentId}:/{fileName}:/createUploadSession
    Content-Type: application/json
    
    {
      "item": {
        "@microsoft.graph.conflictBehavior": "fail"
      },
      "deferCommit": true
    }
    

    For OneDrive Personal, explicit completion is performed with a final PUT; the zero-length POST completion method is documented only for OneDrive for Business and SharePoint. ^1^

    This separates byte transfer from publication and lets the application cancel before initiating commit. It does not provide a documented ordering guarantee once the explicit commit PUT and DELETE are concurrent. Enforce application-level coordination so only one process can begin either operation for a session—for example, atomically transition a shared session record from uploading to either committing or cancelling.

    For a contractual guarantee stronger than this published behavior, the required next step is a Microsoft support request containing timestamps, request IDs, the OneDrive Personal account type, and sanitized request/response traces; the public Graph v1.0 documentation does not specify stronger race semantics.


    References

    1. driveItem: createUploadSession
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.