Skip to content

Retry Drive's 409 Conflict when tests clean up - #461

Draft
shcheklein wants to merge 2 commits into
mainfrom
retry-conflict-in-tests
Draft

shcheklein wants to merge 2 commits into
mainfrom
retry-conflict-in-tests

Conversation

@shcheklein

@shcheklein shcheklein commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Live CI failed three times today at the end of a test, after the test itself passed:

ERROR at teardown of test_Files_Update_File
pydrive2.files.ApiRequestError: <HttpError 409 when requesting https://www.googleapis.com/drive/v3/files/1spq...?supportsAllDrives=true returned "Conflict". Details: "[{'message': 'Conflict', 'domain': 'global', 'reason': 'conflict'}]">

The cleanup from #447 deletes each test's files. Drive sometimes answers that delete with 409 Conflict when the file has just changed: the three cases followed a content update (test_Files_Update_File, test_Files_Update_File_Keeps_Filename) and a conversion to a Google Doc (test_GFile_Conversion_Remove_BOM). They failed on #453 and #460, which do not touch these tests.

The tests' retry helper, pydrive_retry, now retries a 409 whose reason is conflict, as it retries rate limits and server errors. Other 409s, such as fileIdInUse, still fail at once. When the retries run out, the error now carries Drive's answer.

Test-only change. The filesystem does not retry a 409 Conflict on delete either. That is a separate question, because nothing so far shows a user hitting it.

🤖 Generated with Claude Code

Drive sometimes answers 409 Conflict to a delete right after the file
changed, which failed the cleanup of three live tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pydrive2/test/test_util.py Resolved

@shcheklein shcheklein left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI generated — Copilot]

5-pass review summary: sensible fix for Drive's transient 409 Conflict during test teardown. Worth narrowing the 409 check to reason == "conflict" to avoid multi-minute CI stalls on permanent 409 errors.

Comment thread pydrive2/test/test_util.py Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the targeted test-helper retry and diagnostic changes.

No open issues 🎉

What changed in this PR

Reduces intermittent live-test cleanup failures by extending the test retry helper. Production filesystem behavior is unchanged.

Changes:

  • Retries HTTP 409 only when Drive reports the reason as conflict.
  • Includes the original API error in retry failures and preserves exception chaining.
File Description
pydrive2/​test/​test_util.py Adds targeted conflict retries and clearer failure diagnostics.

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants