fix: handle JSON file download from OneDrive /content endpoint#1023
Open
vgrem wants to merge 3 commits into
Open
fix: handle JSON file download from OneDrive /content endpoint#1023vgrem wants to merge 3 commits into
vgrem wants to merge 3 commits into
Conversation
added 3 commits
June 18, 2026 12:09
The OData response processor relies solely on Content-Type header to decide whether to parse the response body as OData JSON. For OneDrive's /content endpoint, a .json file returns application/json, causing the client to incorrectly parse the file contents as an OData response instead of returning raw bytes. Fix: add _is_content_download() check that skips JSON parsing for FunctionQuery operations named 'content' (OneDrive) or '$value' (SharePoint), which always represent raw file content downloads. Fixes #944, #598
Replace _is_content_download name matching with a explicit return_raw_content flag on FunctionQuery. Callers set the flag at construction time — cleaner and extensible.
Replace getattr hack in _is_content_download with a proper isinstance + property check directly on the query object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes downloading
.jsonfiles from OneDrive viaDriveItem.download().Problem
The OData response processor in
process_response()relies solely on theContent-Typeheader to decide whether to parse the body as OData JSON or return raw bytes. When downloading a.jsonfile from OneDrive, the Graph/contentendpoint returnsapplication/json, causing the client to parse the file contents as an OData response instead of returning raw bytes.The SharePoint
$valueendpoint doesnt have this issue because it returnsapplication/octet-stream.Fix
Added
_is_content_download()static method that checks if the query is aFunctionQuerynamed"content"(OneDrive) or"$value"(SharePoint) — these always represent raw file content. When true, the response body is returned as raw bytes regardless of Content-Type.Changes
office365/runtime/odata/request.py: 11 insertions, 1 deletionFixes #944, #598
Testing
$value(should continue working)