Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughSe hizo opcional la relación de dirección en pedidos: el servicio acepta Changes
Esfuerzo estimado de revisión de código🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poema
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/modules/users/orders/order.service.js (1)
52-116:⚠️ Potential issue | 🟠 MajorNo uses truthy/falsy para decidir si se envió
addressId.En Line 52 (
addressId ? ... : null) y Line 109 (if (resolvedAddressId)), valores inválidos como0o""quedan tratados como “no enviado”, se saltea validación y ownership check.💡 Ajuste sugerido
- const resolvedAddressId = addressId ? parsePositiveInteger(addressId, "addressId") : null; + const resolvedAddressId = addressId == null + ? null + : parsePositiveInteger(addressId, "addressId"); - if (resolvedAddressId) { + if (resolvedAddressId !== null) { const address = await prisma.addresses.findFirst({ where: { id_address: resolvedAddressId, fk_user: resolvedUserId, status: true } });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/modules/users/orders/order.service.js` around lines 52 - 116, The code treats falsy values (like 0 or "") as "not sent" because resolvedAddressId is set with addressId ? ... : null and later checked with if (resolvedAddressId); change this to detect presence explicitly: assign resolvedAddressId using a null check (e.g., resolvedAddressId = addressId === undefined || addressId === null ? null : parsePositiveInteger(addressId, "addressId")) and replace the conditional if (resolvedAddressId) with if (resolvedAddressId !== null) so zero or empty-string inputs get validated/parsed instead of being skipped; reference resolvedAddressId and parsePositiveInteger to locate the changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/modules/users/orders/order.service.js`:
- Line 142: La persistencia de fk_address como null rompe porque
Orders.fk_address en Prisma es requerido y mapOrderResponse (función
mapOrderResponse que accede a order.address.id_address) asume siempre una
address; arreglalo en dos pasos: 1) actualizar el modelo Prisma para que
fk_address sea Int? y la relación address opcional (migración correspondiente)
para permitir null en tx.orders.create cuando sea retiro en tienda; 2) hacer
mapOrderResponse null-safe: antes de acceder a order.address.id_address
comprueba que order.address exista (usar comprobación explícita u optional
chaining dentro de mapOrderResponse) y devuelve valores nulos o alternativos
apropiados cuando no haya address.
---
Outside diff comments:
In `@src/modules/users/orders/order.service.js`:
- Around line 52-116: The code treats falsy values (like 0 or "") as "not sent"
because resolvedAddressId is set with addressId ? ... : null and later checked
with if (resolvedAddressId); change this to detect presence explicitly: assign
resolvedAddressId using a null check (e.g., resolvedAddressId = addressId ===
undefined || addressId === null ? null : parsePositiveInteger(addressId,
"addressId")) and replace the conditional if (resolvedAddressId) with if
(resolvedAddressId !== null) so zero or empty-string inputs get validated/parsed
instead of being skipped; reference resolvedAddressId and parsePositiveInteger
to locate the changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ef8e218c-1d19-4ac1-93f0-7d75bf538790
📒 Files selected for processing (1)
src/modules/users/orders/order.service.js
Summary by CodeRabbit