Skip to content

🤖 Fix event products endpoint 500 response (TypeError)#1272

Open
Leonard013 wants to merge 1 commit into
HiEventsDev:developfrom
Leonard013:bugfix/issue-1268-products-filtering-crash
Open

🤖 Fix event products endpoint 500 response (TypeError)#1272
Leonard013 wants to merge 1 commit into
HiEventsDev:developfrom
Leonard013:bugfix/issue-1268-products-filtering-crash

Conversation

@Leonard013

Copy link
Copy Markdown

🤖 Fix Event Products endpoint 500 response

Description

This pull request resolves a 500 internal server error on the /api/events/{event_id}/products route.

Root Cause

In GetProductsHandler::handle, $productPaginator->getCollection() returns a collection of ProductDomainObjects. However, this collection was passed directly to $this->productFilterService->filter(...).

The ProductFilterService::filter method expects a collection of ProductCategoryDomainObjects and processes it by calling $category->getProducts() inside a flatMap closure. Since ProductDomainObject does not implement getProducts(), this mismatch triggers a PHP strict typing TypeError (or an Error for undefined method depending on configuration).

Fix

  1. Isolated the product-specific filtering logic inside ProductFilterService into a new public method filterProducts(Collection $products, ...): Collection.
  2. Refactored ProductFilterService::filter to call filterProducts internally to avoid code duplication and preserve existing functionality for category-based filtering.
  3. Updated GetProductsHandler to invoke the new filterProducts method on the retrieved ProductDomainObject collection.
  4. Added unit test suite under backend/tests/Unit/Services/Application/Handlers/Product/GetProductsHandlerTest.php that verifies:
    • Handler integration behaves as expected.
    • The type mismatch correctly throws a TypeError in filter under the original implementation parameters.

All backend unit tests pass successfully.

Closes #1268 🤖

@Leonard013

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

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.

🐛500 response route: /events/{event_id}/products

1 participant