Skip to content

Reject Drive API v2 field names instead of dropping them - #425

Draft
shcheklein wants to merge 3 commits into
mainfrom
reject-v2-fields
Draft

shcheklein wants to merge 3 commits into
mainfrom
reject-v2-fields

Conversation

@shcheklein

@shcheklein shcheklein commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

A program written for PyDrive2 1.x names a file with title and places it with a parent object:

file = drive.CreateFile({"title": "Hello.txt", "parents": [{"id": folder_id}]})
file.SetContentString("Hello")
file.Upload()

In 2.0 this upload succeeds and creates a file named "Untitled" in the root of My Drive. Drive API v3 ignores every field it does not know, and the local object still returns file["title"].

What Drive v3 does with v2 metadata

The first two commits are a temporary live test that sent v2 forms to Drive and printed the result (first run, second run).

v2 form Result on Drive
title on create file named "Untitled"
title on update name unchanged
createdDate, modifiedDate, lastViewedByMeDate, labels, indexableText ignored
a made-up field ignored
parents: [{"id": folder}] on create file in the root of My Drive
parents: [{"id": folder}] on update 404 "File not found: {'id': ...}"
properties as a list of {key, value, visibility} stored as properties named key, value and visibility
permission withLink, additionalRoles ignored
permission value 400, emailAddress is required
title in q or orderBy 400 "Invalid Value"

Changes

  • Upload() raises ValueError for a renamed v2 file field and names the v3 field: title, createdDate, modifiedDate, lastViewedByMeDate, labels, indexableText, thumbnail.
  • Upload() raises TypeError for parent objects and for a list of properties.
  • InsertPermission() raises ValueError for value, withLink, additionalRoles and expirationDate.
  • All of these are raised before any request is sent. Nothing is translated: the error says which v3 field to use.
  • The upgrade guide lists the date fields and describes the errors.

Reads and queries are unchanged. file["title"], and title in q or orderBy, already fail with an error.

Validation

  • Offline tests cover every rejected field on create and on update, and check that no request is sent. They fail without the change.
  • No README, docs or example snippet uses a v2 form, and none of the rejected names exists in the Drive v3 File or Permission schema.
  • expirationDate was not sent to Drive, because that needs a real user to share with. It is rejected on the strength of the other permission fields being ignored.
  • CI checks on the final commit.

🤖 Generated with Claude Code

shcheklein and others added 3 commits December 1, 2026 07:28
A temporary live test. It uploads, shares and lists with v2 names such as
title and modifiedDate, and fails with a report of what Drive returned. The
fix that follows replaces it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The first run showed that Drive accepts {"parents": [{"id": ...}]} without
an error. This run records where such a file is placed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Drive v3 ignores fields it does not know. A file uploaded with title is
named "Untitled", one uploaded with parent objects lands in the root of
My Drive, and a list of properties is stored under the wrong keys.
Upload() and InsertPermission() now raise for these v2 forms before they
send anything.

This also removes the temporary probe test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

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.

1 participant