whoami returns a bare HTTP 400 when the token has no user behind it (org auth tokens)

Đang mở Phù hợp với người mới
#2,315 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, authentication

Hướng nghiên cứu

Đọc packages/mcp-core/src/internal/error-handling.ts và theo dõi cách whoami xử lý phản hồi 400 từ /auth/. Cập nhật lỗi hiển thị trong trường hợp này để giải thích rằng token không được liên kết với người dùng nào và khuyến nghị dùng personal token hoặc OAuth. Hoàn thành khi lỗi đưa ra hướng dẫn đó và cách xử lý chung hiện có vẫn phù hợp với các lỗi khác; issue không nêu tên tệp kiểm thử nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

mcp-feedback-pattern

An agent connected to the hosted MCP with a direct Sentry-Bearer token got 403s naming org:read on find_organizations and find_projects and event:read on search_issues, and then whoami failed with a bare HTTP 400 Bad Request. It concluded the token "has no usable scopes" and stopped. Reported through submit_feedback_to_sentry_team (MCP 0.42.0).

Likely token type (inference: we can't see the token). These failures fit an org auth token (sntrys_...):

  • Org auth tokens carry only org:ci. It's the only allowed scope (sentry src/sentry/models/orgauthtoken.py:32-36), so every read tool gets an insufficient_scope 403. Since getsentry/toolkit#2222, the MCP names the missing scopes correctly.
  • Org auth tokens authenticate with no user (OrgAuthTokenAuthentication passes None as the user, sentry src/sentry/api/authentication.py:751-787). GET /api/0/auth/ then returns a bodiless 400 when request.user isn't authenticated (sentry src/sentry/api/endpoints/auth_index.py:63-65).

MCP gap. whoami passes that 400 through the generic Input Error template ("There was an HTTP 400 error... trying again", packages/mcp-core/src/internal/error-handling.ts). That message doesn't tell the agent the token isn't tied to a user, or that org auth tokens can't drive the MCP.

Fix. whoami should explain a 400 from /auth/: the token isn't tied to a user, org auth tokens only carry org:ci, so connect with a personal token or OAuth.

Possible follow-up, not in the fix: reject sntrys_ tokens up front in Sentry-Bearer mode, since no read tool can work with org:ci alone.

Reports: 1

via automation evt_905b9c478746fd9deeb853f85ad7441b · Run ID dispatch_d428b39c5339ad27cbfcee6c1a8f7e77.

--

View Session [Sentry]

Ngôn ngữ chính
TypeScript
Star
975
Fork
189
Merge trung bình
19 giờ 57 phút
Pull request đã merge (30 ngày)
542

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/toolkit

Tất cả issue của getsentry/toolkit

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.