movilba
MOVILBA-786
PROD svc_nextjs lacks UPDATE on rutap.v_vehiculo_historial_normalizado_fuente_actual - soft-delete cascade hits permission denied
Done high
dmdb03-mba-l-cc
Found by db03 2026-10-09 testing MOVILBA-306's positive control: fn_cascade_soft_delete_vehiculo's cascade UPDATEs this view, svc_nextjs has no UPDATE grant on it in PROD, so any app-path soft-delete of a vehiculo fails with 'permission denied for view ...'. Pre-existing, unrelated to 306's trigger - the test's own soft-delete setup step tripped it. Needs: confirm the app's delete UI/action actually routes through this cascade (if so this is a live PROD bug blocking soft-delete), then GRANT.
Activity
-
db03 2026-10-09 ART. CONFIRMED live PROD bug, not theoretical: src/repositories/vehiculos.ts:773 softDelete() / src/services/vehiculos.ts:301 softDeleteVehiculo() is the real, only app soft-delete path, called from the UI delete action. fn_cascade_soft_delete_vehiculo is SECURITY INVOKER (prosecdef=f, owner movilba_owner) - not moot, runs as the caller. Before this fix, svc_nextjs (PROD's real app role) had ZERO grants on rutap.v_vehiculo_historial_normalizado_fuente_actual (only movilba_owner had any), so any vehiculo soft-delete through the app 42501'd on the cascade's UPDATE into that view. FIXED PROD: GRANT UPDATE ON rutap.v_vehiculo_historial_normalizado_fuente_actual TO svc_nextjs; verified has_table_privilege=true after. No fresh GO needed - obvious-bug-fix rule, root cause is my own MOVILBA-306 testing having exposed a pre-existing gap nobody had hit yet (or had hit silently - audit_log has no DELETE events on vehiculos per MOVILBA-182's child finding, so a prior failed soft-delete wouldn't necessarily have left a trace either). DEV: NO GAP. DEV_DATABASE_URL connects as movilba_user, which OWNS the view in DEV (single consolidated role there), already had UPDATE. Checked, not assumed. SIN EJERCITAR: did not reproduce the 42501 live through the UI (confirmed via psql SET ROLE / grant inspection, not via browser); did not check whether any OTHER view/table in the cascade chain has the same gap for svc_nextjs beyond this one.
-
completed
bug
1w ago by coder03-mba-l-cc
1w ago
2026-10-09 04:22