`core.getIDToken` discards the original error, so callers cannot tell a network failure from an HTTP error

Đang mở Phù hợp với người mới
#2,565 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ệ
node.js, typescript
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Tìm phần triển khai core.getIDToken trong toolkit và đọc cách xử lý lỗi khi yêu cầu token thất bại. Kiểm tra cách các bài kiểm thử bao quát lỗi mạng và lỗi HTTP, sau đó chạy các bài kiểm thử liên quan. Hoàn thành khi lỗi được ném ra giữ lại lỗi ban đầu làm cause, bảo toàn các trường như code và statusCode.

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

Mô tả

What happened?

core.getIDToken sometimes fails because of a transient network error, for
example socket hang up or a TLS disconnect (see #2098 and #1441). An action
that calls getIDToken should be able to retry those failures and fail fast on
a real HTTP error, such as a 403.

The action cannot do that. getIDToken throws a new Error that holds only a
formatted message. The original error is not attached as cause, and the
thrown error has no code or statusCode. The only way to tell a dropped
connection from a 403 is to parse the message text.

Example

A local server stands in for ACTIONS_ID_TOKEN_REQUEST_URL. In one case it
destroys the socket. In the other case it returns 403. With @actions/core
3.0.1:

try { await core.getIDToken('aud') }
catch (e) { console.log({ message: e.message, cause: e.cause, code: e.code, statusCode: e.statusCode }) }
== socket destroyed
{ message: 'Error message: Failed to get ID Token. \n \n        Error Code : undefined\n \n        Error Message: socket hang up',
  cause: undefined, code: undefined, statusCode: undefined }
== HTTP 403
{ message: 'Error message: Failed to get ID Token. \n \n        Error Code : 403\n \n        Error Message: forbidden',
  cause: undefined, code: undefined, statusCode: undefined }

Expected: The thrown error keeps the original error as cause, so a caller
can read cause.code (ECONNRESET) or cause.statusCode (403).

Ngôn ngữ chính
TypeScript
Star
5.9k
Fork
1.8k
Merge trung bình
15 phút
Pull request đã merge (30 ngày)
1

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

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 actions/toolkit

Tất cả issue của actions/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.