Skip to content

VSN-1998 : Improving the previous logic of checking on importation completion to cover importation outcome result as an expressive message.

yassine.elazami a demandé de fusionner VSN-1998 vers develop

Importation Status Handling Refactor & Enhancement

Overview

This merge request introduces a significant refactor and functional enhancement around importation status handling, with the goal of making the import process more robust, expressive, and production-ready.
The main focus is to replace a simplistic boolean-based feedback mechanism with a structured response model capable of conveying richer contextual information, especially in failure scenarios.

This improvement allows both backend and frontend layers to better understand whether the last importation succeeded, why it failed, and what errors were encountered, while also aligning the codebase with the latest shared starter dependencies.


Motivation

Previously, the importation feature relied on a Boolean return type to indicate success or failure.
This approach had several limitations:

  • No way to expose multiple error messages
  • Lack of extensibility for future status metadata
  • Tight coupling between controller logic and internal service checks
  • Limited observability of real import failure causes

This MR addresses those limitations by introducing a dedicated DTO, improving service logic, and refining controller exposure.


Key Functional Changes

1. Introduction of a Dedicated Importation Status DTO

  • Added a new record-based response DTO to represent the result of the last importation.
  • The DTO encapsulates:
    • A success flag indicating whether the process completed successfully
    • A list of error messages describing failure causes when applicable

This design enables clearer communication between backend services and client consumers.


2. Service Contract Refactoring

  • Refactored the importation service method signature:
    • Before: returned a Boolean
    • After: returns the newly introduced LastImportationStatusDTO

This change improves semantic clarity and prepares the service layer for future extensions without breaking contracts again.


3. Import Error Repository Integration

  • Injected the import error repository into the import service.
  • This allows the service to:
    • Retrieve persisted import errors
    • Aggregate them into a structured list
    • Expose them through the response DTO

As a result, failure cases now provide actionable insights instead of a generic failure flag.


4. Error Handling Improvements

  • Refactored error message handling:
    • Error messages are now handled as a list of strings
    • This supports multiple validation or processing errors within a single import execution
  • Removed temporary test blocks related to status checks to ensure clean, production-grade logic

5. Improved Last Importation Status Resolution

  • Enhanced the internal logic used to determine the status of the last importation.
  • The service now relies on real persisted data instead of partial or hardcoded checks.
  • This ensures correctness even when:
    • The importation table is empty
    • Previous imports failed partially
    • Errors were logged asynchronously

6. Controller Layer Refactoring

  • Refactored controller endpoints to align with the new DTO-based response.
  • The controller now:
    • Acts purely as an exposure layer
    • Delegates all business logic to the service
    • Returns a clear, structured response to API consumers

This separation improves maintainability and testability.


7. Dependency Alignment

  • Updated the starter parent project reference to the latest available release.
  • This ensures compatibility with shared components and benefits from upstream fixes and improvements.

Commit Breakdown

  • feat: Defining importation status response DTO
  • refactor: Updating service method signature to return structured status
  • feat: Injecting import error repository into service
  • refactor: Supporting multiple error messages instead of a single string
  • refactor: Improving last importation status resolution logic
  • refactor: Removing temporary test blocks
  • refactor: Controller adaptation to new response model
  • refactor: Updating starter parent project version
  • docs: Changelog update

Benefits

  • Richer and clearer API responses
  • Better error transparency for frontend and monitoring tools
  • Cleaner service and controller responsibilities
  • Future-proof importation status handling
  • Improved maintainability and extensibility

Notes

No breaking changes were introduced at the API level in terms of endpoint paths, but response payload structure has evolved, and consumers are expected to adapt to the new DTO format.

Changelog has been updated accordingly to reflect these changes.

Closes VSN-1998

Rapports de requête de fusion