Skip to content

Dev#2

Merged
Raydberg merged 4 commits intomainfrom
dev
Oct 8, 2025
Merged

Dev#2
Raydberg merged 4 commits intomainfrom
dev

Conversation

@Raydberg
Copy link
Copy Markdown
Contributor

@Raydberg Raydberg commented Oct 8, 2025

Summary by CodeRabbit

  • New Features
    • Se habilitan nuevas rutas en la configuración de seguridad: /security/oauth2/, /security/login/oauth2/, /security/test/** y /billing/payments/**.
  • Bug Fixes
    • Respuestas de fallback unificadas con estado HTTP 503 y mensajes descriptivos en español para billing, chat, clases, miembros, notificaciones y seguridad.
  • Refactor
    • Simplificación y unificación de la ruta de fallback genérica.
    • Limpieza y consolidación de reglas en la configuración de seguridad, eliminando entradas obsoletas.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 8, 2025

Warning

Rate limit exceeded

@Raydberg has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 03ef691 and 44ff9aa.

📒 Files selected for processing (1)
  • .github/workflows/sonarcloud.yml (1 hunks)

Walkthrough

Se estandarizan las respuestas de los endpoints de fallback para devolver ResponseEntity con estado 503 y mensajes en español. Se simplifica el mapeo genérico a un único @RequestMapping("/{service}"). Se actualizan los path matchers de seguridad para permitir nuevas rutas de OAuth2, pruebas y pagos, consolidando la configuración.

Changes

Cohorte / Archivo(s) Resumen de cambios
Fallbacks HTTP 503 unificados
src/main/java/com/gateway/fallback/FallbackController.java
Métodos de fallback cambian de String a ResponseEntity<String> con HTTP 503; mensajes en español para billing, chat, classes, members, notifications y security; mapeo genérico consolidado a @RequestMapping("/{service}").
Ajustes de rutas en seguridad
src/main/java/com/gateway/security/SecurityConfig.java
Actualiza pathMatchers: añade /security/oauth2/**, /security/login/oauth2/**, /security/test/**, y /billing/payments/**; mantiene /fallback/**; elimina líneas comentadas y consolida el bloque.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Cliente
  participant GW as Gateway
  participant FB as FallbackController
  Note over C,GW: Solicitud a servicio no disponible
  C->>GW: HTTP request
  GW->>FB: Redirección a fallback (p.ej. /fallback/{service})
  FB-->>GW: ResponseEntity 503 (Servicio no disponible)
  GW-->>C: HTTP 503 con mensaje en español
Loading
sequenceDiagram
  autonumber
  participant C as Cliente
  participant Sec as SecurityConfig (Filter Chain)
  Note over C,Sec: Evaluación de rutas permitidas
  C->>Sec: GET /security/login/oauth2/...
  alt Ruta permitida por pathMatchers
    Sec-->>C: Permitir acceso (según config)
  else Ruta no permitida
    Sec-->>C: Aplicar reglas de seguridad (auth/deny)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

Brinco entre rutas, con orejas al sol,
si un micro se cae, 503 es mi rol.
En la puerta de OAuth2 dejo pasar,
y a pagos de billing los veo llegar.
Conejo guardián, fallback sin temor,
gateway ordenado, ¡listo el servidor! 🐇🚦

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive El título propuesto “Dev” es demasiado genérico y no refleja los cambios claves de la solicitud, lo que impide comprender rápidamente el alcance de las modificaciones en los controladores de fallback y la configuración de seguridad. Por favor, emplea un título descriptivo que resuma la principal modificación, por ejemplo: “Unificar respuestas de fallback con HTTP 503 y actualizar rutas de seguridad”.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Raydberg Raydberg merged commit 369530f into main Oct 8, 2025
1 check passed
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 8, 2025

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/com/gateway/fallback/FallbackController.java (1)

19-53: Considerar eliminar los fallbacks específicos o aclarar su propósito.

Los métodos específicos de fallback (billing, chat, classes, members, notifications, security) duplican exactamente la funcionalidad del handler genérico en las líneas 12-16. Esto introduce:

  1. Duplicación de código: Los seis métodos tienen la misma estructura y lógica
  2. Posible conflicto de enrutamiento: El @RequestMapping("/{service}") genérico podría entrar en conflicto con los @GetMapping específicos, creando ambigüedad en la resolución de rutas

Recomendaciones:

  • Opción 1 (recomendada): Eliminar los métodos específicos y usar solo el handler genérico, que ya maneja todos los servicios
  • Opción 2: Si los mensajes personalizados por servicio son importantes, considerar usar un mapa de configuración en lugar de métodos separados

Aplica este diff para eliminar la duplicación (Opción 1):

-    @GetMapping("/billing")
-    public ResponseEntity<String> billingServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de facturación no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/chat")
-    public ResponseEntity<String> chatServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de chat no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/classes")
-    public ResponseEntity<String> classesServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de clases no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/members")
-    public ResponseEntity<String> membersServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de miembros no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/notifications")
-    public ResponseEntity<String> notificationsServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de notificaciones no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/security")
-    public ResponseEntity<String> securityServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de autenticacion no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-

O aplica este diff para la Opción 2 (usar un mapa de mensajes):

+    private static final Map<String, String> SERVICE_MESSAGES = Map.of(
+        "billing", "El servicio de facturación no está disponible en este momento. Por favor, inténtalo más tarde.",
+        "chat", "El servicio de chat no está disponible en este momento. Por favor, inténtalo más tarde.",
+        "classes", "El servicio de clases no está disponible en este momento. Por favor, inténtalo más tarde.",
+        "members", "El servicio de miembros no está disponible en este momento. Por favor, inténtalo más tarde.",
+        "notifications", "El servicio de notificaciones no está disponible en este momento. Por favor, inténtalo más tarde.",
+        "security", "El servicio de autenticación no está disponible en este momento. Por favor, inténtalo más tarde."
+    );
+
     @RequestMapping(value = "/{service}")
     public ResponseEntity<String> genericServiceFallback(@PathVariable String service) {
-        String body = String.format("El servicio '%s' no está disponible en este momento. Por favor, inténtalo más tarde.", service);
+        String body = SERVICE_MESSAGES.getOrDefault(service, 
+            String.format("El servicio '%s' no está disponible en este momento. Por favor, inténtalo más tarde.", service));
         return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(body);
     }
-
-    @GetMapping("/billing")
-    public ResponseEntity<String> billingServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de facturación no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/chat")
-    public ResponseEntity<String> chatServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de chat no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/classes")
-    public ResponseEntity<String> classesServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de clases no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/members")
-    public ResponseEntity<String> membersServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de miembros no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/notifications")
-    public ResponseEntity<String> notificationsServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de notificaciones no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
-
-    @GetMapping("/security")
-    public ResponseEntity<String> securityServiceFallback() {
-        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
-                .body("El servicio de autenticacion no está disponible en este momento. Por favor, inténtalo más tarde.");
-    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06197d3 and 03ef691.

📒 Files selected for processing (2)
  • src/main/java/com/gateway/fallback/FallbackController.java (1 hunks)
  • src/main/java/com/gateway/security/SecurityConfig.java (1 hunks)
🔇 Additional comments (3)
src/main/java/com/gateway/fallback/FallbackController.java (1)

12-16: LGTM! Buen manejo genérico de fallbacks.

La implementación del fallback genérico es correcta y maneja adecuadamente el servicio no disponible con estado 503.

src/main/java/com/gateway/security/SecurityConfig.java (2)

44-46: Confirmar protección de endpoints de prueba en producción

No se encontraron perfiles ni condiciones que deshabiliten /security/test/** en producción; verifica manualmente que estos endpoints estén protegidos o deshabilitados.


49-49: Validar seguridad de /billing/payments/**.

No se detectan controladores ni anotaciones (@Secured/@PreAuthorize) para estos endpoints; asegúrate de que el servicio de billing:

  • Aplique su propia autenticación/autorización.
  • O reciba solo webhooks de pasarelas con validación de firma.

return "El servicio de autenticacion no está disponible en este momento. Por favor, inténtalo más tarde.";
public ResponseEntity<String> securityServiceFallback() {
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
.body("El servicio de autenticacion no está disponible en este momento. Por favor, inténtalo más tarde.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Corregir error ortográfico.

Falta tilde en "autenticación".

Aplica este diff:

-                .body("El servicio de autenticacion no está disponible en este momento. Por favor, inténtalo más tarde.");
+                .body("El servicio de autenticación no está disponible en este momento. Por favor, inténtalo más tarde.");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.body("El servicio de autenticacion no está disponible en este momento. Por favor, inténtalo más tarde.");
.body("El servicio de autentición no está disponible en este momento. Por favor, inténtalo más tarde.");
🤖 Prompt for AI Agents
In src/main/java/com/gateway/fallback/FallbackController.java around line 52,
the response message string has a missing accent in "autenticación"; update the
literal to "El servicio de autenticación no está disponible en este momento. Por
favor, inténtalo más tarde." so the word "autenticación" includes the proper
tilde.

@coderabbitai coderabbitai Bot mentioned this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant