Skip to content

request_service.search() parameters ignored #424

@dfdan

Description

@dfdan

Package version (if known): present in 4.1.2

Describe the bug

I noticed that requests_service.search() does not correctly handle some parameters including 'type' and 'status' to filter the search. Searching with these parameters has no effect, meaning that unwanted requests are returned.

Steps to Reproduce

In an running instance's flask shell -

  1. Use requests_search without these parameters, eg:
In [117]: foo=rs.search(system_identity, receiver={"user": "7"}, topic={"community":"988b42c2-9dc8-4b88-8f79-921d59cde71c"}).to_dict()['hits']['hits']

In [118]: foo
Out[118]: 
[{'id': '02a6b08d-3b39-4ca3-b8c2-d920381280fe',
  'created': '2025-01-28T09:37:06.619302+00:00',
  'updated': '2025-01-28T09:37:08.412501+00:00',
  'links': {'actions': {},
   'self': 'https://12test0.dev.hasdai.org/api/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe',
   'self_html': 'https://12test0.dev.hasdai.org/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe',
   'comments': 'https://12test0.dev.hasdai.org/api/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe/comments',
   'timeline': 'https://12test0.dev.hasdai.org/api/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe/timeline'},
  'revision_id': 3,
  'type': 'community-invitation',
  'title': 'Invitation to join "group b"',
  'description': 'You will join as "Reader".',
  'number': '1h',
  'status': 'accepted',
  'is_closed': True,
  'is_open': False,
  'expires_at': '2025-02-27T09:37:06.608235+00:00',
  'is_expired': False,
  'created_by': {'community': '988b42c2-9dc8-4b88-8f79-921d59cde71c'},
  'receiver': {'user': '7'},
  'topic': {'community': '988b42c2-9dc8-4b88-8f79-921d59cde71c'}}]
  1. Note there is a single request of type 'community-invitation' for this user/community.
  2. Do another search that should exclude this one - for example type='review-request'
In [119]: foo=rs.search(system_identity, receiver={"user": "7"}, topic={"community":"988b42c2-9dc8-4b88-8f79-921d59cde71c"}, type="review-request").to_dict()['hits']['hits']

In [120]: foo
Out[120]: 
[{'id': '02a6b08d-3b39-4ca3-b8c2-d920381280fe',
  'created': '2025-01-28T09:37:06.619302+00:00',
  'updated': '2025-01-28T09:37:08.412501+00:00',
  'links': {'actions': {},
   'self': 'https://12test0.dev.hasdai.org/api/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe',
   'self_html': 'https://12test0.dev.hasdai.org/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe',
   'comments': 'https://12test0.dev.hasdai.org/api/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe/comments',
   'timeline': 'https://12test0.dev.hasdai.org/api/requests/02a6b08d-3b39-4ca3-b8c2-d920381280fe/timeline'},
  'revision_id': 3,
  'type': 'community-invitation',
  'title': 'Invitation to join "group b"',
  'description': 'You will join as "Reader".',
  'number': '1h',
  'status': 'accepted',
  'is_closed': True,
  'is_open': False,
  'expires_at': '2025-02-27T09:37:06.608235+00:00',
  'is_expired': False,
  'created_by': {'community': '988b42c2-9dc8-4b88-8f79-921d59cde71c'},
  'receiver': {'user': '7'},
  'topic': {'community': '988b42c2-9dc8-4b88-8f79-921d59cde71c'}}]
  1. This search should return 0 requests, however the (unwanted) community-invite is still present.
  2. I have verifed the status parameter is also ignored in the same way. topic and reciever work as expected.

Expected behavior

requests_search() should allow filtering on these parameters. Filtering by type is tested in invenio-communities (and probably elsewhere):

https://github.com/inveniosoftware/invenio-communities/blob/4d626f1c97e4487926d7e4ec7b820c6411a06342/tests/members/test_members_services.py#L288

However it looks to me like this test only passes because no other requests exist in the test enviroment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions