depurar-checks-ci-github-actions
⚙ skill: depurar-checks-ci
feat: integración webhook Lemon Squeezy  Open  2 checks fallando
📦 cultivaia/cultiva-plataforma 🔀 PR #47 🌿 feat/integracion-webhook-lemon-squeezy → main 👤 @dani-cultiva 📅 2026-06-14
2
Checks fallando
4
Checks pasando
3
Tests rotos
2
Fixes propuestos
📋 Estado de checks — PR #47
test / unit (ubuntu-latest)
CI · Run #18472301
2m 34s
ver log ↗
lint
CI · Run #18472302
41s
ver log ↗
build
CI · Run #18472303
1m 12s
ver log ↗
e2e / chromium (ubuntu-latest)
CI · Run #18472304
3m 07s
ver log ↗
security / dependency-review
CI · Run #18472305
28s
ver log ↗
typecheck
CI · Run #18472306
55s
ver log ↗
🔍 Logs extraídos — Fragmentos de fallo
test / unit (ubuntu-latest)
Run #18472301 · Job #29841057 · feat/integracion-webhook-lemon-squeezy @ a3f9c12e8b1d
12026-06-14T09:12:01Z▶ Run Vitest unit tests
22026-06-14T09:12:01Z $ vitest run --reporter=verbose
32026-06-14T09:12:03Z
42026-06-14T09:12:03Z ✓ src/lib/payments.test.ts (12 tests) 234ms
52026-06-14T09:12:04Z ✓ src/lib/auth.test.ts (8 tests) 112ms
62026-06-14T09:12:04Z ✗ src/lib/webhook.test.ts (3 failed)
72026-06-14T09:12:04Z
82026-06-14T09:12:04Z ● webhook.test.ts › verifyWebhookSignature › should return false for invalid HMAC
92026-06-14T09:12:04Z
102026-06-14T09:12:04Z AssertionError: expected undefined to be false
112026-06-14T09:12:04Z at Object.<anonymous> (src/lib/webhook.test.ts:34:5)
122026-06-14T09:12:04Z
132026-06-14T09:12:04Z ● webhook.test.ts › verifyWebhookSignature › should accept valid signature
142026-06-14T09:12:04Z
152026-06-14T09:12:04Z TypeError: verifyWebhookSignature is not a function
162026-06-14T09:12:04Z at Object.<anonymous> (src/lib/webhook.test.ts:18:5)
172026-06-14T09:12:04Z
182026-06-14T09:12:04Z ● webhook.test.ts › processLemonSqueezyEvent › should handle order_created event
192026-06-14T09:12:04Z
202026-06-14T09:12:04Z Error: Cannot read properties of undefined (reading 'email')
212026-06-14T09:12:04Z at processLemonSqueezyEvent (src/lib/webhook.ts:67:28)
222026-06-14T09:12:04Z at Object.<anonymous> (src/lib/webhook.test.ts:52:5)
232026-06-14T09:12:04Z
242026-06-14T09:12:04Z Test Files 1 failed (1)
252026-06-14T09:12:04Z Tests 3 failed | 20 passed (23)
262026-06-14T09:12:04Z Duration 2534ms
272026-06-14T09:12:04Z Error: Process completed with exit code 1.
lint
Run #18472302 · Job #29841062 · feat/integracion-webhook-lemon-squeezy @ a3f9c12e8b1d
12026-06-14T09:11:48Z▶ Run ESLint + TypeScript check
22026-06-14T09:11:48Z $ eslint . --ext .ts,.tsx && tsc --noEmit
32026-06-14T09:11:49Z ESLint: no warnings found.
42026-06-14T09:11:50Z
52026-06-14T09:11:50Z src/lib/webhook.ts:23:14 - error TS2355:
62026-06-14T09:11:50Z A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.
72026-06-14T09:11:50Z 23 export function verifyWebhookSignature(payload: string, secret: string) {
82026-06-14T09:11:50Z ~~~~~~~~~~~~~~~~~~~~~~~~~~
92026-06-14T09:11:50Z
102026-06-14T09:11:50Z src/lib/webhook.ts:67:28 - error TS2339:
112026-06-14T09:11:50Z Property 'email' does not exist on type 'LemonSqueezyEventData'.
122026-06-14T09:11:50Z 67 const userEmail = event.data.email;
132026-06-14T09:11:50Z ~~~~~~~~~~
142026-06-14T09:11:50Z
152026-06-14T09:11:50Z Found 2 errors.
162026-06-14T09:11:50Z Error: Process completed with exit code 1.
🛠 Plan de corrección (pendiente de aprobación)
📝
Plan de corrección — PR #47
2 issues raíz → 2 cambios concretos · Archivos afectados: src/lib/webhook.ts · Requiere aprobación explícita antes de aplicar.
⏳ Esperando aprobación
1
Añadir return type + valor de retorno a verifyWebhookSignature()
La función declara que valida una firma HMAC-SHA256 de Lemon Squeezy pero le falta el return final (solo tiene un if early-return vacío). TypeScript error TS2355 + tests que reciben undefined en lugar de boolean. Corrección: declarar retorno : boolean y añadir return false como valor de cierre.
📄 src/lib/webhook.ts · líneas 23-38
@@ -23,7 +23,7 @@
- export function verifyWebhookSignature(payload: string, secret: string) {
+ export function verifyWebhookSignature(payload: string, secret: string): boolean {
const hash = createHmac('sha256', secret)
.update(payload, 'utf8')
.digest('hex');
const sig = payload.split('X-Signature: ')[1]?.split('\n')[0] ?? '';
if (timingSafeEqual(Buffer.from(hash), Buffer.from(sig))) {
return true;
}
+ return false;
}
2
Corregir acceso al email en processLemonSqueezyEvent()
El tipo LemonSqueezyEventData anida el email dentro de data.attributes.user_email según la API de Lemon Squeezy, no directamente en data.email. Error TS2339 + crash en runtime al leer propiedad de undefined. Corrección: ajustar el acceso al path correcto del objeto + añadir optional chaining como guard.
📄 src/lib/webhook.ts · línea 67
@@ -65,5 +65,5 @@
const eventType = event.meta.event_name;
- const userEmail = event.data.email;
+ const userEmail = event.data.attributes?.user_email;
if (!userEmail) {
throw new Error('Missing user email in webhook payload');
}
Comando sugerido tras aplicar el plan:
$ python scripts/inspect_pr_checks.py --repo . --pr 47 --json
$ gh pr checks 47
Aprobación requerida antes de implementar
El plan propone 2 cambios en src/lib/webhook.ts. Una vez aprobado, se aplicarán los diffs, se ejecutarán los tests localmente y se sugerirá actualizar el PR.