Dropbox and Google Drive: the token refresh check fails on text errors and Dropbox refreshes on every 401
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in CloudAppTrait::sendRequest() to see how the parsed body reaches accessTokenNeedsRefresh(int $code, ?object $message = null) in DropboxApp and GoogleDriveApp, and in ResponseParser::parseBody() to confirm a non-JSON body comes back as a string. Widen both signatures to mixed and handle only object bodies, then change the Dropbox condition to || so only the tags in ACCESS_TOKEN_STATUS refresh. Done means new tests with a mocked HTTP client cover a 401 with a text body, a 401 with an unrelated .tag, and a 401 with expired_access_token refreshing exactly once.
索引モデルが issue の本文から書いたものです。
説明
Summary
The Dropbox and Google Drive storage adapters decide after a failed API request whether the access token must be refreshed. That check fails in two ways.
Problems
-
A
TypeErrorfor an error response that is not JSON.CloudAppTrait::sendRequest()passes the response body toaccessTokenNeedsRefresh(int $code, ?object $message = null)inDropboxAppandGoogleDriveApp.ResponseParser::parseBody()returns an object only for a JSON response and the raw text otherwise, and Dropbox answers some errors withtext/plain. Withstrict_types, the text causes aTypeError(Argument #2 ($message) must be of type ?object, string given) instead of theExceptionwith the API's error text thatsendRequest()throws for errors that are not about the token. -
Dropbox refreshes the token on every 401.
DropboxApp::accessTokenNeedsRefresh()reads:if (!isset($error['.tag']) && !in_array($error['.tag'], self::ACCESS_TOKEN_STATUS)) { return false; } return true;With
&&the method returnstruewhenever the error has a.tag, whatever its value, so a 401 that is not about the token (for example a missing permission) refreshes the token and retries.sendRequest()retries by calling itself, so the same 401 starts the next refresh: the request repeats until PHP gives up. Without a.tag, the code reads$error['.tag']anyway and raises a warning. The condition should use||, so onlyinvalid_access_tokenandexpired_access_tokenrefresh the token.
Both are in 3.1.x as well; they are fixed in 3.2.0.
Fix
accessTokenNeedsRefresh()in both apps accepts the response body as it comes (mixed) and reads the error only from an object; a text body is not a token error, sosendRequest()throws itsExceptionwith that text.DropboxApprefreshes only for the.tagvalues inACCESS_TOKEN_STATUS.- Tests with a mocked HTTP client: a 401 with a text body throws the
Exception; a 401 with another.tagthrows without refreshing; a 401 withexpired_access_tokenrefreshes and retries once.
- 主要言語
- PHP
- スター
- 43
- フォーク
- 22
- 平均マージ
- 54分
- マージ済み PR(30日)
- 57
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quantum-php/framework のほかの issue
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
quantum-php/framework#692 ·
メンテナーはふだん 1 日以内に返信
-
routing testing
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
quantum-php/framework#547 ·
メンテナーはふだん 1 日以内に返信
-
refactoring tech debt
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
quantum-php/framework#693 ·
メンテナーはふだん 1 日以内に返信
-
install:debugbar reads the package folder from the working directory and uses the default storage adapter対応中かも @armanist が今日担当しました。 オープンbug console debugbar good first issue
quantum-php/framework#691 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
console enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 74/100
quantum-php/framework#688 ·
メンテナーはふだん 1 日以内に返信
quantum-php/framework の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
ajeetraina/awesome-docker-sbx#559 ·
-
dependencies enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
novalo-dev/Prestashop-MCP-Server#329 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
bug origin:interactive status:available
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Ultimate-Multisite/ultimate-multisite#2131 ·
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信