createBankTransactionAttachmentByFileName hangs on non-JSON response from Xero API
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, nodejs, typescript
- Ambito
- api
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 264
- Fork
- 177
- Merge medio
- 10h 5m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di XeroAPI/xero-node
-
`getClientCredentialsToken()` sends `scopes` (comma-joined) instead of the OAuth `scope` parameterAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 55/100
-
TrackingOptionId value missing from accountingApi.getInvoices()Forse già presa @miachillgood l’ha presa 152 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 18/100
-
BankTransaction type is missing the batchPayment object.Forse già presa @miachillgood l’ha presa 171 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 22/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
Tutte le issue di XeroAPI/xero-node
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
super-productivity/super-productivity#12128 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
A docs change can fail pnpm check, because outreach lint and gen:types both write .astro/ at onceForse già presa @2389400626lh-ops l’ha presa oggi. ApertaArea: Infrastructure Area: Outreach Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
DouglasNeuroInformatics/OpenDataCapture#1956 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
justyns/silverbullet-ai#199 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
spartan-ng/spartan#1931 ·
I maintainer di solito rispondono entro 2 giorni