Category: Testing & Quality
Difficulty: High
Description:
The CreatePaymentBody Zod schema validates idempotencyKey as IdempotencyKeySchema = z.string().uuid(). If a non-UUID value is passed (e.g., "not-a-uuid"), the handler at line 618 calls CreatePaymentBody.parse(request.body) which will throw a ZodError caught by the global error handler, returning a 400 VALIDATION_ERROR. However, there is no test that verifies:
- A non-UUID idempotency key returns 400 with
VALIDATION_ERROR code
- A UUID idempotency key longer than 255 characters is rejected (line 623–625)
- A valid UUID key passes through to the idempotency check
- A key that is exactly
null or an empty string is treated as "no key provided"
The payment-idempotency.test.ts file rebuilds its own idempotency logic and does not test the Zod validation.
Location:
services/api-gateway/src/index.ts:617–625, shared/validation/schemas.ts:258–259
Acceptance Criteria:
Technical Notes:
- Generate a 256-char string:
'a'.repeat(256).
- An empty string key should be treated the same as missing key (the
trim() check at line 129).
Category: Testing & Quality
Difficulty: High
Description:
The
CreatePaymentBodyZod schema validatesidempotencyKeyasIdempotencyKeySchema = z.string().uuid(). If a non-UUID value is passed (e.g.,"not-a-uuid"), the handler at line 618 callsCreatePaymentBody.parse(request.body)which will throw a ZodError caught by the global error handler, returning a 400VALIDATION_ERROR. However, there is no test that verifies:VALIDATION_ERRORcodenullor an empty string is treated as "no key provided"The
payment-idempotency.test.tsfile rebuilds its own idempotency logic and does not test the Zod validation.Location:
services/api-gateway/src/index.ts:617–625,shared/validation/schemas.ts:258–259Acceptance Criteria:
idempotencyKey: "not-a-uuid", expect 400idempotencyKey, confirm payment is created without idempotencyIDEMPOTENCY_KEY_MAX_LEN(255) matches the Prisma schema's implicitString?limitTechnical Notes:
'a'.repeat(256).trim()check at line 129).