Search⌘ K
AI Features

The Repository

Understand how to update the repository layer to support filter parameters for efficient data retrieval in a clean architecture Python application. Learn to handle errors properly, adjust the repository API to use filters, and run tests validating multiple filter conditions. This lesson prepares you to integrate external storage capabilities and ensures your Flask app returns correct filtered results.

Exception from the previous lesson

If we run the Flask development web server now and try to access the /rooms endpoint, we’ll get the following response:

{"type": "SystemError", "message": "TypeError: list() got an unexpected keyword argument 'filters'"}

The HTTP 500 error we see in the HTTP response is exactly the same as the mapping of our SystemError use case error, which in turn signals a Python exception.

Update the repository

This error comes from the repository, which hasn’t been migrated to the new API. To tackle this, we need to change the list method of the MemRepo class so that it accepts the filters parameter ...