Skip to content

Commit

Permalink
Ensure that offset and limit are never negative
Browse files Browse the repository at this point in the history
And set minimum limit consistently to 1 ... 0 doesn't seem to have much
utility but would also be an option.

Fixes part of #18043.
  • Loading branch information
mvdbeek committed Apr 23, 2024
1 parent 8f4968f commit 4bc09c0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/api/folder_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
Path(..., title="Folder ID", description="The encoded identifier of the library folder."),
]

LimitQueryParam: int = Query(default=10, title="Limit", description="Maximum number of contents to return.")
LimitQueryParam: int = Query(default=10, ge=1, title="Limit", description="Maximum number of contents to return.")

OffsetQueryParam: int = Query(
default=0,
ge=0,
title="Offset",
description="Return contents from this specified position. For example, if ``limit`` is set to 100 and ``offset`` to 200, contents between position 200-299 will be returned.",
)
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@
description="Sort results by specified field.",
)

LimitQueryParam: int = Query(default=500, title="Limit", description="Maximum number of jobs to return.")
LimitQueryParam: int = Query(default=500, ge=1, title="Limit", description="Maximum number of jobs to return.")

OffsetQueryParam: int = Query(
default=0,
ge=0,
title="Offset",
description="Return jobs starting from this specified position. For example, if ``limit`` is set to 100 and ``offset`` to 200, jobs 200-299 will be returned.",
)
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/api/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@
description="Sort in descending order?",
)

LimitQueryParam: int = Query(default=100, lt=1000, title="Limit number of queries.")
LimitQueryParam: int = Query(default=100, ge=1, lt=1000, title="Limit number of queries.")

OffsetQueryParam: int = Query(
default=0,
ge=0,
title="Number of pages to skip in sorted query (to enable pagination).",
)

Expand Down
5 changes: 4 additions & 1 deletion lib/galaxy/webapps/galaxy/api/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,11 @@ def __get_stored_workflow(self, trans, workflow_id, **kwd):
description="Sort in descending order?",
)

LimitQueryParam: Optional[int] = Query(default=None, title="Limit number of queries.")
LimitQueryParam: Optional[int] = Query(default=None, ge=1, title="Limit number of queries.")

OffsetQueryParam: Optional[int] = Query(
default=0,
ge=0,
title="Number of workflows to skip in sorted query (to enable pagination).",
)

Expand Down Expand Up @@ -1229,6 +1230,7 @@ def show_workflow(
InvocationsLimitQueryParam = Annotated[
Optional[int],
Query(
ge=1,
title="Limit",
description="Limit the number of invocations to return.",
),
Expand All @@ -1237,6 +1239,7 @@ def show_workflow(
InvocationsOffsetQueryParam = Annotated[
Optional[int],
Query(
ge=0,
title="Offset",
description="Number of invocations to skip.",
),
Expand Down

0 comments on commit 4bc09c0

Please sign in to comment.