jira icon indicating copy to clipboard operation
jira copied to clipboard

maxResults=5000 in sprints_by_name() still returns only 50 sprints

Open Akash-kansal opened this issue 2 months ago • 1 comments

Bug summary

Code Snippet

def sprints_by_name(self, board_id: int, sprint_name: str) -> str:
    """
    Finds a specific sprint within a board by its name.
    """
    try:
        log_info(f"Searching for sprint '{sprint_name}' in board '{board_id}'")
        sprints = self.jira.sprints(board_id, maxResults=5000)  # <-- only 50 returned

        matching_sprints = [s for s in sprints if s.name == sprint_name]

        if not matching_sprints:
            return json.dumps({"error": f"Sprint '{sprint_name}' not found in board '{board_id}'."})

        if len(matching_sprints) > 1:
            return json.dumps({"error": f"Multiple sprints found with the name '{sprint_name}'. Please use a unique name."})

        sprint = matching_sprints[0]
        sprint_details = {
            "id": sprint.id,
            "name": sprint.name,
            "state": sprint.state,
            "goal": getattr(sprint, 'goal', 'No goal set.'),
            "startDate": getattr(sprint, 'startDate', None),
            "endDate": getattr(sprint, 'endDate', None),
        }
        return json.dumps(sprint_details, default=str)
    except Exception as e:
        logger.error(f"Failed to get sprint by name: {e}")
        return json.dumps({"error": str(e)})

Steps to Reproduce

  1. Use sprints_by_name(board_id=<valid_board_id>, sprint_name=<existing_sprint_name>)
  2. The board must contain more than 50 sprints.
  3. Observe that even though maxResults=5000 is set, the API still returns only 50 sprints.

Expected Behavior

Should return up to 5000 sprints as requested (or at least respect the maxResults parameter).

Actual Behavior

Only 50 sprints are returned — the Jira API appears to enforce a pagination limit.

Only 50 sprints are returned — the Jira API appears to enforce a pagination limit.


Environment

  • Python Jira library: jira==3.10.5
  • Python version: 3.11
  • Platform: macOS
  • Jira instance: Cloud

Is there an existing issue for this?

  • [x] I have searched the existing issues

Jira Instance type

Jira Cloud (Hosted by Atlassian)

Jira instance version

3.10.5

jira-python version

3.10.5

Python Interpreter version

3.11

Which operating systems have you used?

  • [ ] Linux
  • [x] macOS
  • [ ] Windows

Reproduction steps

1. Use `sprints_by_name(board_id=<valid_board_id>, sprint_name=<existing_sprint_name>)`
2. The board must contain more than 50 sprints.
3. Observe that even though `maxResults=5000` is set, the API still returns only **50 sprints**.

Stack trace

Returning only 50 results

Expected behaviour

It should give max result

Additional Context

No response

Akash-kansal avatar Oct 30 '25 08:10 Akash-kansal

This behavior seems to be caused by a Jira Cloud REST API limitation, not the jira-python client.

The endpoint: /rest/agile/1.0/board/{boardId}/sprint ignores maxResults values above 50, even though the parameter is accepted. Atlassian has confirmed this as a known issue (JSWCLOUD-18382). As a result, the server will never return more than 50 sprints in a single request.

To retrieve all sprints, you must paginate using startAt in steps of <=50 and combine the results client-side. The library cannot bypass this server-side restriction.

niljub avatar Nov 22 '25 02:11 niljub