Skip to content

fix(openqa-list-incidents): replace asserts with error handling#580

Open
okurz wants to merge 1 commit into
os-autoinst:masterfrom
okurz:fix/style_list_incidents
Open

fix(openqa-list-incidents): replace asserts with error handling#580
okurz wants to merge 1 commit into
os-autoinst:masterfrom
okurz:fix/style_list_incidents

Conversation

@okurz
Copy link
Copy Markdown
Member

@okurz okurz commented May 11, 2026

Motivation:
Using 'assert' for runtime validation is discouraged as they can be optimized
away and provide poor error messages to the user.

Design Choices:

  • Replaced 'assert' calls in 'get_api_url' with explicit checks that call
    'sys.exit' with descriptive error messages.

Benefits:
More robust error handling and improved user feedback when unexpected API
results occur.

Comment thread openqa-list-incidents
job = pathlib.Path(url.path).name.removeprefix("t")

assert job.isdigit()
if not job.isdigit():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that comes from the openqa API resp, if that ever happens means that we do something wrong in openQA

Comment thread openqa-list-incidents
except RequestException as error:
sys.exit(f"ERROR: {job}: {error}")
assert len(data) == 1
if len(data) != 1:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this also looks wrong -
I tried

❯ ./openqa-list-incidents "https://openqa.opensuse.org/tests/overview?distri=aeon&distri=microos&distri=opensuse&version=Tumbleweed&build=20260511&groupid=1"
ERROR: https://openqa.opensuse.org/tests/overview?distri=aeon&distri=microos&distri=opensuse&version=Tumbleweed&build=20260511&groupid=1: expected 1 job, got 488

Copy link
Copy Markdown
Contributor

@d3flex d3flex left a comment

Choose a reason for hiding this comment

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

I suggest to remove both asserts. there is not serve any really value as is. or the validations should be different

Motivation:
Using 'assert' for runtime validation is discouraged as they can be optimized
away and provide poor error messages to the user.

Design Choices:
- Replaced 'assert' calls in 'get_api_url' with explicit checks that call
  'sys.exit' with descriptive error messages.

Benefits:
More robust error handling and improved user feedback when unexpected API
results occur.
@okurz okurz force-pushed the fix/style_list_incidents branch from f7be600 to 1d0d776 Compare May 21, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants