createBankTransactionAttachmentByFileName hangs on non-JSON response from Xero API

オープン
#479 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, nodejs, typescript
領域
api

調査の方向性

The failing parse is in the compiled dist/gen/api/accountingApi.js inside the request callback of createBankTransactionAttachmentByFileName, where JSON.parse(body) runs unguarded. The code is generated from the XeroAPI/Xero-OpenAPI spec, so the fix may belong in the generator templates rather than the output. Done means a non-JSON response such as an nginx 500 page rejects the promise with an error instead of hanging. Check first whether the upstream generator already handles this, since the issue has been stale for years.

索引モデルが issue の本文から書いたものです。

説明

SDK you're using (please complete the following information):

  • Version 4.9.1

Describe the bug
createBankTransactionAttachmentByFileName hangs when it receives non-JSON response from Xero API. uncaughtException is triggered, but Promise never resolves or rejects.

To Reproduce

  1. createBankTransactionAttachmentByFileName saves files by calling Xero API - i.e.https://api.xero.com/api.xro/2.0/BankTransactions/**id-redacted**/Attachments/h3h33sjg-rec.jpg
  2. However this endpoint sometimes fails and returns this body. (I tried saving this same file about 10 times, in the same way, the endpoint was failing and then succeeded on the last try.)
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx</center>
</body>
</html>
  1. When bad body is received, it fails to parse to JSON - this line fails: body = JSON.parse(body)
SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/node_modules/xero-node/dist/gen/api/accountingApi.js:310:41)

Expected behavior
Well, Xero API shouldn't be failing to save files in the first place. But when it does fail, xero-node should catch JSON parse error and call reject.

Additional context
Happy to provide failing transactionIDs, etc. on request

主要言語
TypeScript
スター
264
フォーク
177
平均マージ
10時間 5分
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

XeroAPI/xero-node のほかの issue

XeroAPI/xero-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。