Skip to content

fix: circular JSON in buyCrypto update response#3750

Closed
TaprootFreak wants to merge 1 commit into
developfrom
fix/buycrypto-circular-json
Closed

fix: circular JSON in buyCrypto update response#3750
TaprootFreak wants to merge 1 commit into
developfrom
fix/buycrypto-circular-json

Conversation

@TaprootFreak
Copy link
Copy Markdown
Collaborator

Problem

PUT /v1/buyCrypto/:id (und PUT /v1/buyCrypto/:id/amlCheck) liefern auf PRD HTTP 500:

TypeError: Converting circular structure to JSON
  --> starting at object with constructor 'UserData'
  |   property 'kycSteps' -> object with constructor 'Array'
  |   index 7 -> object with constructor 'KycStep'
  --- property 'userData' closes the circle

Ursache

BuyCryptoController.update gibt die rohe BuyCrypto-Entity zurück. buyCryptoService.update() lädt sie mit transaction.userData.kycSteps. TypeORM setzt beim Laden die Rückreferenz KycStep.userData auf den Parent → zyklischer Objektgraph → JSON.stringify in res.json() wirft.

manualPassAmlCheck delegiert an update() und ist damit identisch betroffen.

Die kycSteps-Relation kam per #3139 ("fix missing relation triggerVideoIdent") rein — unabhängig von der PostgreSQL-Migration. Es gibt keinen globalen ClassSerializerInterceptor, der Zyklen abfangen würde.

Fix

kycSteps wird für die interne Update-Logik gebraucht, kann also nicht weggelassen werden. Daher lädt update() die Entity am Ende für die Response neu — ohne die zyklischen userData-Collections (kycSteps, users). Die Response-Felder bleiben sonst identisch.

Test plan

  • PUT /v1/buyCrypto/{id} für einen BuyCrypto, dessen userData KYC-Steps hat → 200 statt 500
  • PUT /v1/buyCrypto/{id}/amlCheck → 200, AML-Logik unverändert
  • Response enthält weiterhin buy/cryptoRoute/transaction/bankData etc.

BuyCryptoController.update and manualPassAmlCheck returned the raw
BuyCrypto entity loaded with transaction.userData.kycSteps. TypeORM
populates the KycStep.userData inverse back-reference, producing a
circular object graph that JSON.stringify rejects -> 500 on
PUT /v1/buyCrypto/:id.

The kycSteps relation is required by the update logic, so reload the
entity without the cyclic userData collections for the response.
@davidleomay
Copy link
Copy Markdown
Member

Duplicate of #3748

@davidleomay davidleomay marked this as a duplicate of #3748 May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants