Skip to content

fix: Add strict UUID validation for proposal_id

Edouard Legoupil requested to merge fix/template-loading-error-handling into main_dev

Created by: Edouard-Legoupil

This commit introduces stricter validation for proposal_id across the backend API to prevent database errors caused by invalid input from the frontend.

The following changes have been made:

  • The Pydantic models in backend/models/schemas.py have been updated to define proposal_id as a uuid.UUID type. This enforces type validation at the API boundary for all relevant request bodies.
  • The save_draft function in backend/api/proposals.py has been updated to correctly handle uuid.UUID objects, ensuring they are converted to strings when returned in the JSON response.
  • The load_draft function in backend/api/proposals.py now includes a manual validation step to ensure that proposal_id for non-sample drafts is a valid UUID.
  • The delete_draft function in backend/api/proposals.py now uses uuid.UUID in its path parameter for automatic validation by FastAPI.
  • The load_draft function now correctly includes the proposal_id in its response for user-created drafts, fixing a bug that caused the frontend to receive an undefined proposal_id.
  • Error logging has been improved in the proposals API to use logger.error instead of print.

These changes make the backend more robust and resilient to invalid data from the frontend, preventing the sqlalchemy.exc.DatabaseError that was occurring.

  • Does my code meet the quality standards for releasing packages?
  • Does the reviewer have all the information to validate the features/issues without too much research?
  • Does the customer who will validate the associated tickets have the information to do so without wasting time?

Issues to validate to close :

  • issue #

Processed issues to keep open or in progress:

  • issue #

Checklist:

  • Does the package check go local?
  • Does the CI pass?
  • Are the added / fixed features documented, tested?
  • Are the added features / solved problems briefly presented in the PR message?
  • Are the changes related to tickets / issues that I have listed in the commits and in the PR itself?
  • Are the tickets in "review" mode in the Project Tracking Board?
  • Does each ticket, if it is to be closed after acceptance of the PR, contain a comment that tells how to validate it?

Merge request reports

Loading