[BUG] Device-flow login raises JSONDecodeError or KeyError instead of the token endpoint HTTP error
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
Start with lib/crewai-core/src/crewai_core/auth/oauth2.py and inspect AuthenticationCommand._poll_for_token, which the issue identifies as the failing poll loop. Check existing tests for device-flow token polling and cover non-200 responses with invalid JSON and JSON lacking an error field. Done means these responses raise an httpx.HTTPError that reports the endpoint status or OAuth error; an open linked pull request #9823 indicates work is already underway.
索引モデルが issue の本文から書いたものです。
説明
Description
The device-flow poll loop in lib/crewai-core/src/crewai_core/auth/oauth2.py (AuthenticationCommand._poll_for_token) reads the response body before looking at the status code, and then indexes token_data["error"] unconditionally:
while time.monotonic() < deadline:
response = httpx.post(
self.oauth2_provider.get_token_url(), data=token_payload, timeout=30
)
token_data = response.json()
if response.status_code == 200:
...
if token_data["error"] == "expired_token":
break
if token_data["error"] not in ("authorization_pending", "slow_down"):
raise httpx.HTTPError(
token_data.get("error_description") or token_data.get("error")
)
The loop runs for the lifetime of the device code (minutes). During that window the endpoint can answer with something that is not an OAuth device-flow answer:
- A proxy or gateway in front of the IdP answers
502with an HTML page:response.json()raisesjson.JSONDecodeError: Expecting value: line 1 column 1 (char 0), which is raised out ofcrewai loginwith no indication that the token endpoint returned 502. - A rate limiter answers
429with JSON that has noerrormember (for example{"message": "rate limited"}):token_data["error"]raisesKeyError: 'error'.
In both cases the real failure (an HTTP error from the endpoint) is replaced by a parsing error from the wrong response shape.
Steps to Reproduce
from unittest.mock import MagicMock, patch
import httpx
from crewai_cli.authentication.main import AuthenticationCommand
command = AuthenticationCommand.__new__(AuthenticationCommand)
command.oauth2_provider = MagicMock()
command.oauth2_provider.get_token_url.return_value = "https://idp.example.com/token"
command.oauth2_provider.get_client_id.return_value = "client"
response = MagicMock()
response.status_code = 502
response.json.side_effect = ValueError("Expecting value: line 1 column 1 (char 0)")
with patch("crewai_core.auth.oauth2.httpx.post", return_value=response):
command._poll_for_token({"device_code": "d", "expires_in": 60, "interval": 0})
Actual: ValueError: Expecting value: line 1 column 1 (char 0). With a 429 whose body is {"message": "rate limited"}: KeyError: 'error'.
Expected Behavior
Only a 200 is a device-flow answer; read the body in that branch. For any other status, take the OAuth error from a body that has one, and when it has none raise an httpx.HTTPError that names the HTTP status, so crewai login reports what the endpoint returned rather than a JSON/KeyError from a body it did not expect.
AI assistance
I used an AI coding agent to investigate, reproduce, and prepare this report, and reviewed its results. Per CONTRIBUTING.md, please apply the llm-generated label; external contributors cannot add it with my current permissions.
- 主要言語
- Python
- スター
- 61.2k
- フォーク
- 9.2k
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 180
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
crewAIInc/crewAI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM provider対応中かも @HashimSyedUBC が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Native Azure provider ignores the seed setting対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
crewAIInc/crewAI#9787 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
crewAIInc/crewAI の issue をすべて見る
似ている issue
-
bug harness
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mruangutai/harness#2687 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modal-labs/modal-client#4158 ·
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 72/100
The-Swarm-Corporation/swarms-rs#168 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
linuxserver/docker-healthchecks#137 · コメント 1 件 ·