Error thrown is a String
@miachillgood đang làm issue này rồi.
Từ ngày 19/6/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- nodejs, typescript
- Lĩnh vực
- api
Hướng nghiên cứu
Start with the repro: xero.setTokenSet() with an expired token, then xero.accountingApi.getOrganisations() in a try/catch. The thrown value is a plain string holding the 401 response, not an Error. Check the open PRs #812 and #816 first, since they may already address this. Done means the SDK throws an Error carrying the status code, message and response body, and the other string-throw paths are covered.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- Version 10.0.0 (latest at time of submission)
Step to repro:
If the token set is expired (we should obviously call const ts = await xero.refreshToken();) the error throw in a String instead of an Error object
import { XeroClient } from 'xero-node';
const xero = new XeroClient({
clientId: process.env.XERO_CLIENT_ID,
clientSecret: process.env.XERO_CLIENT_SECRET,
redirectUris: ['.....'],
scopes: [
'openid',
'profile',
'email',
'accounting.transactions',
'offline_access',
'accounting.settings',
'accounting.contacts',
],
state: '...',
});
await xero.initialize();
const tenantId = '22.....5e';
xero.setTokenSet({"id_token":"ey...Q","access_token":"ey...w","expires_at":1740040370,"token_type":"Bearer","refresh_token":"Mk.....","scope":"email profile openid accounting.settings accounting.transactions accounting.contacts offline_access"});
try {
const { body: { organisations } } = await xero.accountingApi.getOrganisations(tenantId);
console.log(organisations);
} catch (err) {
console.log('ERR', typeof err, err);
}
Output:
ERR string {"response":{"statusCode":401,"body":{"Type":null,"Title":"Unauthorized","Status":401,"Detail":"TokenExpired: token expired at 02/20/2025 08:32:50","Instance":"f4a9c0c2-ab46-462c-b70b-9999612e6aa9","Extensions":{}},"headers":{"content-type":"application/json","content-length":"177","server":"nginx","www-authenticate":"Bearer error=invalid_token","xero-correlation-id":"f4a9c0c2-ab46-462c-b70b-9999612e6aa9","expires":"Thu, 20 Feb 2025 12:09:06 GMT","cache-control":"max-age=0, no-cache, no-store","pragma":"no-cache","date":"Thu, 20 Feb 2025 12:09:06 GMT","connection":"close","x-client-tls-ver":"tls1.3","set-cookie":"ak....jQ==; Domain=.xero.com; Path=/; Expires=Thu, 20 Feb 2025 14:09:06 GMT; Max-Age=7200; SameSite=None; Secure"},"request":{"url":{"protocol":"https:","port":443,"host":"api.xero.com","path":"/api.xro/2.0/Organisation"},"headers":{"accept":"application/json","content-type":"application/json","user-agent":"xero-node-10.0.0","xero-tenant-id":"22......5e","authorization":"Bearer ey...Jw","content-length":"2","accept-encoding":"gzip, compress, deflate, br","host":"api.xero.com"},"method":"GET"}},"body":{"Type":null,"Title":"Unauthorized","Status":401,"Detail":"TokenExpired: token expired at 02/20/2025 08:32:50","Instance":"f4a9c0c2-ab46-462c-b70b-9999612e6aa9","Extensions":{}}
There are other cases where the error is a String
It should not throw an error as a string because it's not practical, it should be an Error object with ideally a status code (401, 403, ..), a message, and more data if needed
- Ngôn ngữ chính
- TypeScript
- Star
- 264
- Fork
- 177
- Merge trung bình
- 10 giờ 5 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của XeroAPI/xero-node
-
`getClientCredentialsToken()` sends `scopes` (comma-joined) instead of the OAuth `scope` parameterĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
-
TrackingOptionId value missing from accountingApi.getInvoices()Có thể đã có người làm @miachillgood đã nhận 152 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 18/100
-
BankTransaction type is missing the batchPayment object.Có thể đã có người làm @miachillgood đã nhận 171 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 22/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Tất cả issue của XeroAPI/xero-node
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
super-productivity/super-productivity#12128 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A docs change can fail pnpm check, because outreach lint and gen:types both write .astro/ at onceCó thể đã có người làm @2389400626lh-ops đã nhận hôm nay. Đang mởArea: Infrastructure Area: Outreach Bug Difficulty: Low Good First Issue Priority: Low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DouglasNeuroInformatics/OpenDataCapture#1956 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
justyns/silverbullet-ai#199 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
spartan-ng/spartan#1931 ·
Maintainer thường phản hồi trong vòng 2 ngày