Skip to content

feat: implement global response advice and refine repository workflows - #341

Merged
aniebietafia merged 3 commits into
mainfrom
feat/global_response_body_advice
Jul 6, 2026
Merged

aniebietafia merged 3 commits into
mainfrom
feat/global_response_body_advice

Conversation

@aniebietafia

@aniebietafia aniebietafia commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor
  • Add GlobalResponseBodyAdvice to automatically wrap REST API success responses in the standard ApiResponse envelope.
  • Refactor CurrencyController to return raw DTOs directly, removing manual wrapping boilerplate.
  • Add @order(Ordered.HIGHEST_PRECEDENCE) to global exception advisers to override Spring's default ProblemDetailsExceptionHandler.
  • Remove redundant @ResponseStatus annotations from exception handler methods returning ResponseEntity.
  • Add structured pull_request_template.md and configure domain boundaries in CODEOWNERS.
  • Refactor release.yml to use robust SemVer tag sorting.

Summary by CodeRabbit

  • New Features
    • Added automatic REST response wrapping into a consistent API envelope, with an opt-out marker for endpoints that must return raw bodies.
  • Breaking Changes
    • Currency endpoints now return their payload directly (no API envelope wrapper).
    • Error handling is unified around typed application error codes, affecting the shape/content of error responses.
  • Bug Fixes
    • Improved exception-handler precedence for more predictable error message selection.
  • Tests
    • Added coverage for the new response-wrapping behavior.
  • Chores
    • Updated repository templates and ownership rules; adjusted release tagging/changelog generation workflows.

- Add GlobalResponseBodyAdvice to automatically wrap REST API success responses in the standard ApiResponse envelope.
- Refactor CurrencyController to return raw DTOs directly, removing manual wrapping boilerplate.
- Add @order(Ordered.HIGHEST_PRECEDENCE) to global exception advisers to override Spring's default ProblemDetailsExceptionHandler.
- Remove redundant @ResponseStatus annotations from exception handler methods returning ResponseEntity.
- Add structured pull_request_template.md and configure domain boundaries in CODEOWNERS.
- Refactor release.yml to use robust SemVer tag sorting.

Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 63f10c32-d6e7-4c04-87e6-6a911b227d66

📥 Commits

Reviewing files that changed from the base of the PR and between d8e2a13 and 0eacb2b.

📒 Files selected for processing (17)
  • src/main/java/com/xtraction/api/billing/promocode/exception/InvalidPromoCodeException.java
  • src/main/java/com/xtraction/api/billing/promocode/exception/PromoCodeNotFoundException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/BadRequestException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/BusinessException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/ConflictException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/ErrorCode.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/ForbiddenException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/JwtAuthenticationException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/NotFoundException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/TokenProcessingException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/TooManyRequestsException.java
  • src/main/java/com/xtraction/api/core/exceptions/custom/UnauthorizedException.java
  • src/main/java/com/xtraction/api/core/exceptions/global/GlobalExceptionHandler.java
  • src/main/java/com/xtraction/api/identity/auth/impl/EmailVerificationImpl.java
  • src/main/java/com/xtraction/api/identity/auth/impl/LoginUserImpl.java
  • src/main/java/com/xtraction/api/identity/auth/impl/RefreshTokenImpl.java
  • src/test/java/com/xtraction/api/identity/auth/service/impl/LoginUserImplTest.java
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/xtraction/api/core/exceptions/custom/ErrorCode.java

📝 Walkthrough

Walkthrough

Adds global response wrapping, restructures exception handling around typed error codes, updates authentication flows to use the new error model, and changes release workflow tag logic plus repository ownership and PR template files.

Changes

Response wrapping and business errors

Layer / File(s) Summary
Response wrapping contract
src/main/java/com/xtraction/api/core/web/response/BypassResponseWrapping.java, src/main/java/com/xtraction/api/core/web/response/GlobalResponseBodyAdvice.java, src/test/java/com/xtraction/api/shared/response/GlobalResponseBodyAdviceTest.java
Adds a bypass annotation and ResponseBodyAdvice that wraps eligible REST bodies in ApiResponse, with tests for wrapped, bypassed, already-wrapped, and string responses.
CurrencyController raw payloads
src/main/java/com/xtraction/api/billing/subscription/controller/CurrencyController.java
/convert, /rates, and /supported now return raw payloads directly instead of ResponseEntity<ApiResponse<...>>, and the response-builder dependency is removed.
BusinessException and typed error codes
src/main/java/com/xtraction/api/core/exceptions/custom/ErrorCode.java, src/main/java/com/xtraction/api/core/exceptions/custom/BusinessException.java, src/main/java/com/xtraction/api/core/exceptions/custom/*Exception.java, src/main/java/com/xtraction/api/billing/promocode/exception/*Exception.java
Introduces ErrorCode and BusinessException, then migrates core and promo-code exceptions to typed error codes and updated constructors.
Global exception handling
src/main/java/com/xtraction/api/core/exceptions/global/GlobalExceptionHandler.java, src/main/java/com/xtraction/api/billing/payment/paypal/exception/PayPalGlobalExceptionHandler.java, src/main/java/com/xtraction/api/billing/payment/paystack/exception/PaystackGlobalExceptionHandler.java
Raises handler precedence to highest priority and updates GlobalExceptionHandler to resolve business exceptions via ErrorCode while keeping the response-building path.
Authentication error flow
src/main/java/com/xtraction/api/identity/auth/impl/EmailVerificationImpl.java, src/main/java/com/xtraction/api/identity/auth/impl/LoginUserImpl.java, src/main/java/com/xtraction/api/identity/auth/impl/RefreshTokenImpl.java, src/test/java/com/xtraction/api/identity/auth/service/impl/LoginUserImplTest.java
Email verification, login, and refresh-token paths now throw BusinessException-based errors with ErrorCode values, and the login test stubs the sanitizing dependency.

CI and repository governance

Layer / File(s) Summary
Release workflow logic
.github/workflows/release.yml
The release workflow now derives the latest and previous tags from sorted git tag output and adjusts version-bump and changelog ranges accordingly.
CODEOWNERS and PR template
.github/CODEOWNERS, .github/pull_request_template.md
Adds repository-wide and path-specific code owner mappings and a structured pull request template with metadata and verification sections.

Estimated code review effort: 5 (Critical) | ~120 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

- Update ErrorCode enum to define fallback system, authorization, and promo-code codes.
- Refactor BusinessException to support getErrorCodeEnum() and getErrorCode() for backward compatibility.
- Update custom exception classes to extend BusinessException.
- Consolidate individual custom exception handlers in GlobalExceptionHandler into a single @ExceptionHandler(BusinessException.class).

Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
@aniebietafia aniebietafia linked an issue Jul 6, 2026 that may be closed by this pull request
8 tasks done
Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
@aniebietafia
aniebietafia merged commit 31e7b5a into main Jul 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant