microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

Graph.Drive.Item.Content returns null if the file is empty

Open
#2,839 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs investigation type:bug
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

Describe the bug

Graph.Drive.Item.Content is to be used to return a stream of the file content, however if the file is empty it returns null - this is unexpected because an empty file (stream with length zero) is different from null - happy to be directed to any doco which contradicts this for Graph purposes.

Expected behavior

Should return a stream with length zero

How to reproduce

Upload an empty file and try to download its contents using code like this:

            var content = await graphClient
                .Drives["b!C6YVIzpT60SYqdpHCYpAZXQj2FA-LzVJhxb5VG0bjuh5Q7qKO0dqTpssSrUI12kI"]
                .Items["01ACRBDKP5P323XRKICFA2XSPOZVLGJFSW"]
                .Content
                .GetAsync();

content is null

SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Graph.Drive.Item.Content.GetAsync reproduction with an uploaded empty file and inspect the returned content. Determine whether the SDK or Graph response produces null, then verify the result against the expected zero-length stream behavior. Done means empty files return a non-null stream with length zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.