Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add typed AuthError variants once the runtime distinguishes auth-missing/invalid/unreachable

Đang mở
#1,209 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rust
Lĩnh vực
api, authentication

Hướng nghiên cứu

Công việc này bị chặn bởi github/copilot-agent-runtime#7485; hãy bắt đầu bằng cách đọc issue runtime đó và tìm mapping Error/Rpc hiện có của SDK, vì ở đây không có tệp SDK nào được nêu tên. Khi đã có các wire code riêng biệt, hãy ánh xạ chúng sang AuthErrorKind và giữ nguyên các code không xác định dưới dạng Rpc, sau đó xác minh rằng src-tauri/src/error.rs:115-120 và handlers/auth.rs::emit_copilot_cli_auth_issue không còn yêu cầu so khớp chuỗi hoặc connectivity workaround.

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

Mô tả

enhancement

Context

Companion to github/copilot-agent-runtime#7485 — the runtime today returns identical generic -32603 internal_error payloads for "no token," "invalid token," and "network unreachable." Once the runtime adds distinct codes (e.g., -32001 AuthMissing, -32002 AuthInvalid, -32003 AuthUnreachable), the SDK should expose them as a typed enum so consumers don't string-match.

Proposed shape

pub enum Error {
    Rpc { code: i32, message: String, data: Option<Value> },
    // ...
    Auth(AuthErrorKind),  // new
}

pub enum AuthErrorKind {
    /// No token configured. User needs to sign in.
    Missing,
    /// Token rejected by CAPI (401/403). User needs to reauth.
    Invalid,
    /// Transport failure talking to CAPI. Retry, don't reauth.
    Unreachable { cause: String },
}

The SDK can map known runtime codes to Error::Auth(...) and leave anything else as Error::Rpc { ... }.

What this lets consumers delete

In Copilot Desktop today (src-tauri/src/error.rs:115-120) we string-match three magic phrases:

pub fn is_copilot_auth_failure(&self) -> bool {
    let message = self.to_string().to_ascii_lowercase();
    message.contains("not authenticated")
        || message.contains("authenticate first")
        || message.contains("no authentication info available")
}

Plus the connectivity-tracker workaround in handlers/auth.rs::emit_copilot_cli_auth_issue whose only job is to second-guess whether the runtime's "not authenticated" really means "not authenticated" or "couldn't reach the auth service." Both go away with typed variants.

Dependencies

Blocked on the runtime change (github/copilot-agent-runtime#7485). No useful SDK work to land before the runtime distinguishes the cases on the wire.


  Generated via Copilot (Claude Opus 4.7) on behalf of @tclem

Ngôn ngữ chính
Java
Star
10.5k
Fork
1.5k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
130

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 github/copilot-sdk

Tất cả issue của github/copilot-sdk

Issue tương tự

Thêm issue về Java

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.