Repository navigation
Conversation
…min service/controller
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughResumenSe agrega un nuevo campo CambiosSoporte de icono en categorías
Esfuerzo estimado de revisión de código🎯 2 (Simple) | ⏱️ ~12 minutos PRs posiblemente relacionadas
Revisores sugeridos
Poema
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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/admin/categories/admin-category.service.js (1)
31-70:⚠️ Potential issue | 🟠 Major | ⚡ Quick winValidá y normalizá
iconde forma consistente antes de persistir.Hoy en create no se valida
icon, y en update solo tipo/null. Un valor largo (>500) o sin normalizar puede terminar en error de BD en vez deValidationErrorcontrolado.Propuesta de ajuste
const normalizeAdminCategoryName = (name) => { ... }; +const normalizeCategoryIcon = (icon) => { + if (icon === undefined || icon === null) return null; + if (typeof icon !== "string") { + throw new ValidationError("icon debe ser texto o null"); + } + const normalizedIcon = icon.trim(); + if (normalizedIcon.length > 500) { + throw new ValidationError("icon no puede superar 500 caracteres"); + } + return normalizedIcon || null; +}; export const createAdminProductCategoryService = async (name, icon = null) => { const normalizedName = normalizeAdminCategoryName(name); + const normalizedIcon = normalizeCategoryIcon(icon); ... const createdCategory = await prisma.categories.create({ data: { name: normalizedName, - icon: icon ?? null, + icon: normalizedIcon, visible: true, status: true }, ... }); }; const normalizeUpdatePayload = (payload) => { ... if (payload.icon !== undefined) { - if (payload.icon !== null && typeof payload.icon !== "string") { - throw new ValidationError("icon debe ser texto o null"); - } - data.icon = payload.icon ?? null; + data.icon = normalizeCategoryIcon(payload.icon); } ... };Also applies to: 350-355
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/modules/admin/categories/admin-category.service.js` around lines 31 - 70, The createAdminProductCategoryService currently does not validate or normalize the icon value before saving; update logic only checks type/null. Update createAdminProductCategoryService to validate that icon is either null or a string, normalize it (e.g., trim, collapse whitespace), enforce a maximum length (e.g., 500 chars) and convert empty/whitespace-only to null, and throw a ValidationError on invalid input instead of letting the DB error; apply the same validation/normalization logic to the corresponding update function (e.g., updateAdminProductCategoryService) so both create and update use the same icon rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/modules/admin/categories/admin-category.service.js`:
- Around line 350-355: El servicio updateAdminProductCategoryService no está
incluyendo el campo icon en la respuesta tras actualizar (aunque ya valida y
setea data.icon), por lo que la API queda inconsistente con create/get/list;
updateAdminProductCategoryService debe devolver el icon en el objeto resultante:
ensure the updated response payload (the object returned by
updateAdminProductCategoryService or the value returned from the DB update call)
includes data.icon (or the entity.icon field) so the client receives the updated
icon field consistently; update the return/selection logic in
updateAdminProductCategoryService to include icon alongside the other returned
properties.
---
Outside diff comments:
In `@src/modules/admin/categories/admin-category.service.js`:
- Around line 31-70: The createAdminProductCategoryService currently does not
validate or normalize the icon value before saving; update logic only checks
type/null. Update createAdminProductCategoryService to validate that icon is
either null or a string, normalize it (e.g., trim, collapse whitespace), enforce
a maximum length (e.g., 500 chars) and convert empty/whitespace-only to null,
and throw a ValidationError on invalid input instead of letting the DB error;
apply the same validation/normalization logic to the corresponding update
function (e.g., updateAdminProductCategoryService) so both create and update use
the same icon rules.
🪄 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: 0569ddcc-e474-4bee-ac10-7807ddaecbee
📒 Files selected for processing (4)
prisma/migrations/20260517230841_add_icon_to_categories/migration.sqlprisma/schema.prismasrc/modules/admin/categories/admin-category.controller.jssrc/modules/admin/categories/admin-category.service.js
|



Este PR agrega el campo icon a Categories. Después de hacer pull corran npx prisma generate.
Summary by CodeRabbit
Notas de Lanzamiento