createBankTransactionAttachmentByFileName hangs on non-JSON response from Xero API
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- javascript, nodejs, typescript
- Domaine
- api
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
createBankTransactionAttachmentByFileNamesaves files by calling Xero API - i.e.https://api.xero.com/api.xro/2.0/BankTransactions/**id-redacted**/Attachments/h3h33sjg-rec.jpg- 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>
- 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
- Langage dominant
- TypeScript
- Étoiles
- 264
- Forks
- 177
- Merge moyen
- 10 h 5 min
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de XeroAPI/xero-node
-
`getClientCredentialsToken()` sends `scopes` (comma-joined) instead of the OAuth `scope` parameterOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Difficulté 3/5 Une demi-journée Accessibilité débutants 55/100
-
TrackingOptionId value missing from accountingApi.getInvoices()Peut-être pris @miachillgood l’a pris il y a 152 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 18/100
-
BankTransaction type is missing the batchPayment object.Peut-être pris @miachillgood l’a pris il y a 171 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 22/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 25/100
Toutes les issues de XeroAPI/xero-node
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
super-productivity/super-productivity#12128 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
A docs change can fail pnpm check, because outreach lint and gen:types both write .astro/ at oncePeut-être pris @2389400626lh-ops l’a pris aujourd’hui. OuverteArea: Infrastructure Area: Outreach Bug Difficulty: Low Good First Issue Priority: Low
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
DouglasNeuroInformatics/OpenDataCapture#1956 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 1-3 heures Accessibilité débutants 72/100
justyns/silverbullet-ai#199 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
spartan-ng/spartan#1931 ·
Les mainteneurs répondent en général sous 2 jours