Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request_service.search() parameters ignored #424

Open
dfdan opened this issue Jan 29, 2025 · 0 comments
Open

request_service.search() parameters ignored #424

dfdan opened this issue Jan 29, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@dfdan
Copy link
Member

dfdan commented Jan 29, 2025

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.

@dfdan dfdan added the bug Something isn't working label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant