GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docs: fix the 'list all items in a drive' sample (#1070) by earbona23 · Pull Request #1572 · microsoftgraph/msgraph-sdk-python

Conversation

@earbona23

@earbona23 Eduard Arbona (earbona23) commented Sep 2, 2026

Copy link
Copy Markdown

Fixes #1070 (and the earlier #365, which was closed without a fix).

The bug

Sample 3 in docs/drives_samples.md was:

items = await client.drives.by_drive_id('DRIVE_ID').items.get()   # GET /drives/{id}/items

GET /drives/{id}/items is not an enumerable collection in Microsoft Graph — it
addresses driveItems by id and only answers $filter queries — so following the sample
returns exactly the error nine people reacted to:

The 'filter' query option must be provided.

The SDK and Graph are both behaving correctly; the sample documented a call that cannot
work. #365 reported this and was closed with no fix while the broken sample stayed in place.

The fix

Sample 3 now does what its title says — list all the items — by walking root with
delta and paging through odata_next_link:

page = await client.drives.by_drive_id('DRIVE_ID').items.by_drive_item_id('root').delta.get()
while page:
    if page.value:
        for item in page.value:
            print(item.id, item.name, item.size, item.folder, item.file)
    if not page.odata_next_link:
        break
    page = await client.drives.by_drive_id('DRIVE_ID').items.by_drive_item_id('root').delta.with_url(page.odata_next_link).get()

This also removes an overlap: as written, sample 3 duplicated sample 6 (which lists only the
top level via root/children). Now 3 is the recursive listing and 6 is the top-level one,
with a cross-reference between them so the distinction is explicit.

Verified against the generated SDK in this repo

  • items.by_drive_item_id('root').delta — msgraph/generated/drives/item/items/item/delta/delta_request_builder.py
  • .with_url() for paging — same file, line 65
  • odata_next_link and value on the response — inherited from BaseDeltaFunctionResponse (msgraph/generated/models/base_delta_function_response.py:18)
  • the snippet parses as valid Python

Docs-only, one file. I did not run it against a live drive (no tenant), so if a maintainer
runs it and sees anything off with the paging, tell me and I will adjust — but every symbol
it uses is confirmed present in the generated client.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@earbona23
docs: fix the "list all items in a drive" sample (microsoftgraph#1070, …
31b4fef
…microsoftgraph#365)

Sample 3 called `client.drives.by_drive_id(id).items.get()`, i.e. `GET /drives/{id}/items`.
That path is not an enumerable collection in Microsoft Graph — it addresses driveItems by id
and only answers `$filter` queries — so the sample fails at runtime with
`The 'filter' query option must be provided.` This has been reported repeatedly (microsoftgraph#365, closed
without a fix, and microsoftgraph#1070 with nine reactions), while the broken sample stayed in the docs.

Replace it with a correct, and now distinct, sample: enumerate every item in the drive by
walking `root` with `delta`, paging through `odata_next_link`. That matches the section's
title ("list ALL the items") and no longer overlaps with sample 6, which lists only the top
level via `root/children`. A cross-reference between the two makes the distinction explicit.

Verified against the generated SDK in this repo: `items.by_drive_item_id('root').delta`, its
`with_url()` for paging, and `odata_next_link` / `value` on the delta response all exist. The
snippet parses as valid Python.
@earbona23
Eduard Arbona (earbona23) requested a review from a team as a code owner September 2, 2026 02:26
@earbona23

Eduard Arbona (earbona23) commented Sep 2, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@earbona23
Merge branch 'main' into docs/fix-list-all-drive-items-sample
497572d
@earbona23

Eduard Arbona (earbona23) commented Nov 7, 2026

Copy link
Copy Markdown
Author

A first check-in on this one: it has had no reviewer assigned since I opened it on 2 September, and the request list is empty, so I think it fell through rather than being held back.

Still accurate today. On main, docs/drives_samples.md line 46 is unchanged:

items = await client.drives.by_drive_id('DRIVE_ID').items.get()

That is GET /drives/{id}/items, which is not an enumerable collection, so anyone following sample 3 still gets The 'filter' query option must be provided. — which is #1070, and #365 before it. The PR is one file, docs only, and GitHub reports it MERGEABLE; it is behind main, which for a markdown-only change costs nothing.

Gavin Barron (@gavinbarron), you have been merging non-generated PRs here recently — could you point this at whoever owns docs/, or review it yourself if that is quicker? @microsoftgraph/msgraph-devx-python-write is the code owner but was never asked.

Two honest caveats, unchanged from the description: I did not run the snippet against a live drive, so the shape is verified against the generated request builders in this repo rather than against a tenant; and if these docs are meant to be generated from somewhere upstream rather than edited here, say so and I will close this and file it there instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Error: The 'filter' query option must be provided.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@earbona23
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.