Skip to content

"maxResults" parameter ignored #179

@mblasenstein

Description

@mblasenstein

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:

  1. Load a quantity n of community/post items into a LumApps instance.
  2. Construct a ServerContentCommunityPostPostMessagesPostListRequest request body with an explicit maxResults argument that specifies a number less than n. Call this nmaxResults
  3. Add the appropriate arguments to a get_call method, i.e. the endpoint name community/post/search and the request body.
  4. Call the endpoint with the get_call method 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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions