-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Description
The maxResults parameter is being ignored in the community/posts/search endpoint. Presumably this is not limited to a single endpoint.
A PR fixing this bug is ready to be submitted if issue is approved.
What type of issue is this? (place an x in one of the [ ])
- bug
- enhancement (feature request)
- question
- documentation related
- testing related
- discussion
Requirements (place an x in each of the [ ])
- I've read and understood the Contributing guidelines and have done my best effort to follow them.
- I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
SDK ignores maxResults argument in request body (ServerContentCommunityPostPostMessagesPostListRequest) for endpoint community/post/search. Instead, it returns all items matching the request.
The unexpected result happens regardless of whether the value for maxResults is passed as an integer or string.
This is using the get_call method in the BaseClient.
In contrast, maxResults is honored for endpoint community/post/list. The difference here is that maxResults is passed in the parameters instead of a request body.
(NOTE: Though I haven't tested whether this happens in other scenarios, it seems likely this bug is affecting other endpoints.)
Reproducible in:
lumapps-sdk version: 1.2.0
python version: 3.9.13
OS version(s): OSX 11.6.6 (Big Sur)
Steps to reproduce:
- Load a quantity n of
community/postitems into a LumApps instance. - Construct a
ServerContentCommunityPostPostMessagesPostListRequestrequest body with an explicitmaxResultsargument that specifies a number less than n. Call this nmaxResults - Add the appropriate arguments to a
get_callmethod, i.e. the endpoint namecommunity/post/searchand the request body. - Call the endpoint with the
get_callmethod constructed in step 3.
Expected result:
The get_call execution against the community/post/search endpoint returns nmaxResults results.
Actual result:
The get_call execution against the community/post/search endpoint returns all n results.
Attachments:
This example code will retrieve all n results from the endpoint instead of nmaxResults specified in maxResults.
All n results will be printed to the console.
import json
from lumapps import BaseClient
if __name__ == "__main__":
ACCESS_TOKEN = "<access token>"
client = BaseClient(token=ACCESS_TOKEN)
# Ensure maxResults is less than the total number of community posts.
# This example assumes there are more than 5 community posts in the instance.
community_posts_req = '''
{
"maxResults": 5,
"instanceId": "<instance ID>",
"customerId": "<customer ID>",
"lang": "en",
"contentId": ["<content ID>"],
"followingOnly": false,
"sortOrder": ["-likes", "-updatedAt"],
"postType": ["QUESTION"],
"fields": "items(uid)"
}
'''
community_posts = client.get_call("community/post/search", body=community_posts_req)
print(json.dumps(community_posts, indent=2))