Parameter converter triggers storage exception to be thrown

Created on 2 October 2024, 4 months ago

Problem/Motivation

  1. Whenever SparqlEntityStorageConverter triest to convert an value with an entity type with a non-existing entity type ID, it causes an exception instead of returning NULL (so, users see a 5xx error instead of a 404).
  2. Because the conversion is able to load entities with different storage than SparQL, it unnecessarily dispatches the SparqlEntityStorageEvents::GRAPH_ENTITY_CONVERT event.

Steps to reproduce

This was discovered with a path foo/{entity_type}/{entity} where the entity type is dynamic, and one tries to load the path /foo/missing_type/something. If this module is not installed, then visitors get a 404 response.

Expected: we get a 404 response (because of parameter is not converted)
Actual result: 500 response (PluginNotFoundException).

Proposed resolution

  1. When the entity type is known, so ::applies() can be fully evaluated: check whether there is a definition for the given entity type ID before trying to load the storage. It makes no sense in the current order.
  2. Do the same in ::convert when the entity type is dynamic, (so only ::applies is not invoked)

Remaining tasks

  1. Test
  2. Fix
  3. Review

User interface changes

Nothing.

API changes

SparqlEntityStorageEvents::GRAPH_ENTITY_CONVERT is only fired if a SparQL-stored entity is converted.

Data model changes

Nothing.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary huzooka Hungary πŸ‡­πŸ‡ΊπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024