← Back to team overview

dhis2-devs team mailing list archive

[Bug 1389912] [NEW] (Web-API) Using filter=name:like:* fails for certain objects

 

Public bug reported:

When using a filter query parameter with value 'name:like:<anything>',
HTTP 500 internal server error is thrown for certain (types of) objects.
Only happens for name:like, other property:operator combos behave as
expected.

More specifically, if the object which is being filtered does not have a
'name' parameter in its DB model (Hibernate mapping, table), a HTTP 500
is returned. This is true for several DHIS2 objects, including
messageconversations and interpretations.

Test case:
----------------------------------------
Run:
curl -u admin:district -v "https://apps.dhis2.org/dev/api/interpretations?filter=name:like:test";

Returns:
....
org.hibernate.QueryException: could not resolve property: name of: org.hisp.dhis.interpretation.Interpretation
...

Should return:
Empty json object (no matches)

----------------------------------------

Caused by special case implementation for filter=name:like:* in
AbstractCrudController.getObjectList()

Suggestions:
Could be fixed by somehow checking in the aforementioned special case for the existence of a 'name' property. Unfortunately this is not trivial as property must be defined in the actual Hibernate model (filtering executed in query, I assume?).
Could also be fixed by defining the name property in the mapping (might not be a great idea, depending on the case).

** Affects: dhis2
     Importance: Undecided
         Status: New


** Tags: filter web-api

** Description changed:

  When using a filter query parameter with value 'name:like:<anything>',
  HTTP 500 internal server error is thrown for certain (types of) objects.
  Only happens for name:like, other property:operator combos behave as
  expected.
  
  More specifically, if the object which is being filtered does not have a
  'name' parameter in its DB model (Hibernate mapping, table), a HTTP 500
  is returned. This is true for several DHIS2 objects, including
  messageconversations and interpretations.
  
  Test case:
  ----------------------------------------
  Run:
  curl -u admin:district -v "https://apps.dhis2.org/dev/api/interpretations?filter=name:like:test";
  
- Returns:  
- .... 
- org.hibernate.QueryException: could not resolve property: name of: org.hisp.dhis.interpretation.Interpretation 
+ Returns:
+ ....
+ org.hibernate.QueryException: could not resolve property: name of: org.hisp.dhis.interpretation.Interpretation
  ...
  
  Should return:
  Empty json object (no matches)
  
  ----------------------------------------
  
  Caused by special case implementation for filter=name:like:* in
  AbstractCrudController.getObjectList()
  
  Suggestions:
- Could be fixed by somehow checking in the aforementioned special case for the existence of a 'name' property. Sadly this is not trivial as property must be defined in the actual Hibernate model (filtering executed in query, I assume?). 
+ Could be fixed by somehow checking in the aforementioned special case for the existence of a 'name' property. Unfortunately this is not trivial as property must be defined in the actual Hibernate model (filtering executed in query, I assume?).
  Could also be fixed by defining the name property in the mapping (might not be a great idea, depending on the case).

-- 
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/1389912

Title:
  (Web-API) Using filter=name:like:* fails for certain objects

Status in DHIS 2:
  New

Bug description:
  When using a filter query parameter with value 'name:like:<anything>',
  HTTP 500 internal server error is thrown for certain (types of)
  objects. Only happens for name:like, other property:operator combos
  behave as expected.

  More specifically, if the object which is being filtered does not have
  a 'name' parameter in its DB model (Hibernate mapping, table), a HTTP
  500 is returned. This is true for several DHIS2 objects, including
  messageconversations and interpretations.

  Test case:
  ----------------------------------------
  Run:
  curl -u admin:district -v "https://apps.dhis2.org/dev/api/interpretations?filter=name:like:test";

  Returns:
  ....
  org.hibernate.QueryException: could not resolve property: name of: org.hisp.dhis.interpretation.Interpretation
  ...

  Should return:
  Empty json object (no matches)

  ----------------------------------------

  Caused by special case implementation for filter=name:like:* in
  AbstractCrudController.getObjectList()

  Suggestions:
  Could be fixed by somehow checking in the aforementioned special case for the existence of a 'name' property. Unfortunately this is not trivial as property must be defined in the actual Hibernate model (filtering executed in query, I assume?).
  Could also be fixed by defining the name property in the mapping (might not be a great idea, depending on the case).

To manage notifications about this bug go to:
https://bugs.launchpad.net/dhis2/+bug/1389912/+subscriptions


Follow ups

References