Summary
Fixes an issue where repeatedly clicking "Override to completed" for a user in the Admin console causes an internal server error (HTTP 500).
- Lark bug: https://hola-tech.sg.larksuite.com/record/OR1TrnU9Be9Fhwc6rFqlbcOrghg
- Priority: High
- Module: [Admin] Users & KYC
Root Cause
-
AdminActionLogJSON Transformer Bug:admin-action-log.entity.tsdeclared@Column({ type: 'json', nullable: true, transformer: new ColumnJsonTransformer() }) details: Record<string, unknown> | null;. Because PostgreSQL drivernode-pgalready natively deserializes JSON columns into JavaScript objects on read,ColumnJsonTransformer.from()received an object. When it calledJSON.parse(), it failed with a SyntaxError and fell back into its catch block (value.split(',')). Calling.split()on an object caused a fatalTypeError: value.split is not a function. When an admin overrode KYC, an action log entry with non-nulldetailswas written. Subsequent reads of user details (AdminUsersService.getUserDetailqueryinglistForTarget) crashed with 500 on every reload or subsequent action. -
Sumsub Rate Limits / Intermittent Errors: Repeated clicks to override caused multiple external HTTP requests to Sumsub's
getApplicantendpoint, which could fail due to rate limiting or network issues, bubbling up and failing the override flow.
Changes
-
Entity Fix (
be/src/modules/admin/entities/admin-action-log.entity.ts):- Removed
ColumnJsonTransformerfrom the nativejsoncolumndetails. Node-pg handles serialization and deserialization natively.
- Removed
-
KycService Resilience (
be/src/modules/kyc/services/kyc.service.ts):- Added a
try/catchblock insidefetchApplicantFields: when SumsubgetApplicantfails due to external rate limiting, log a warning and proceed gracefully using any existing valid document fields in DB.
- Added a
-
Tests (
be/src/modules/kyc/services/kyc-override-sumsub-failure.spec.ts):- Added regression unit test verifying that
overrideKycToCompletedsucceeds when the user has valid KYC documents, even if SumsubgetApplicantfails due to rate limits. - Synchronized with
developincorporating MR !156 (merged)'s validation guards against empty KYC records.
- Added regression unit test verifying that
Verification
-
beunit test:pnpm test src/modules/kyc/services/kyc-override-sumsub-failure.spec.tspassed. - All KYC unit tests:
78/78passed. - All Admin backend unit tests:
12/12passed. - Admin portal unit tests:
5/5passed. - Production build:
pnpm buildpassed on bothbeandadmin.