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

Accept the empty string as a falsy value for build_number in list_releases #1531

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions api/src/shipit_api/public/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def good_version(release):
return False


def list_releases(product=None, branch=None, version=None, build_number=None, status=["scheduled"]):
def list_releases(product=None, branch=None, version=None, build_number=None, status=None):
if not status:
status = ["scheduled"]
session = current_app.db.session
releases = session.query(Release)
if product:
Expand All @@ -40,7 +42,7 @@ def list_releases(product=None, branch=None, version=None, build_number=None, st
if version:
releases = releases.filter(Release.version == version)
if build_number:
releases = releases.filter(Release.build_number == build_number)
releases = releases.filter(Release.build_number == int(build_number))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If build_number is not an int this will raise ValueError and presumably turn into a 500, which we don't want.

elif build_number:
raise BadRequest(description="Filtering by build_number without version is not supported.")
releases = releases.filter(Release.status.in_(status))
Expand Down
2 changes: 1 addition & 1 deletion api/src/shipit_api/public/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ paths:
- name: build_number
in: query
schema:
type: integer
type: string
- name: status
in: query
style: form
Expand Down