Skip to content

supervisor: Patch get_previous_erratum logic#372

Merged
TomasTomecek merged 2 commits intopackit:mainfrom
Jazzcort:patch-previous-erratum-logic
Feb 6, 2026
Merged

supervisor: Patch get_previous_erratum logic#372
TomasTomecek merged 2 commits intopackit:mainfrom
Jazzcort:patch-previous-erratum-logic

Conversation

@Jazzcort
Copy link
Collaborator

This function used to fetch the Erratum object after it found the previous erratum. However, we encountered an edge case that the erratum_id from the erratatools API's response of

/api/v1/product_versions/{RHEL version}/released_builds/{package name}

cound be null in REHL 8. To address this, we decide to make this function just return the erratum id and build nvr so we can decide whether we should fetch the Erratum object or not after calling this function.

Also adjust the logic where this function is called.

@Jazzcort Jazzcort requested a review from owtaylor November 25, 2025 14:46
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the get_previous_erratum function to handle an edge case where an erratum ID from the API can be null. The function now returns the erratum ID and build NVR as a tuple, deferring the decision to fetch the full Erratum object to the caller. The changes are correctly propagated to the call sites in erratum_handler.py and issue_handler.py.

My review includes a couple of suggestions to improve maintainability and readability. One suggestion is to refactor a block of code in errata_utils.py for conciseness and to use safer dictionary access. Another suggestion is to centralize the construction of errata advisory URLs to avoid hardcoding them in multiple places.

Copy link
Collaborator

@owtaylor owtaylor left a comment

Choose a reason for hiding this comment

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

The basic idea here is right, but some changes are needed to make it actually do what is intended - handle the case where we have a build nvr but no errata.

@Jazzcort Jazzcort force-pushed the patch-previous-erratum-logic branch 2 times, most recently from 1fc9f13 to d6e8d16 Compare January 29, 2026 19:42
@Jazzcort Jazzcort requested a review from owtaylor January 29, 2026 19:44
Copy link
Collaborator

@owtaylor owtaylor left a comment

Choose a reason for hiding this comment

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

Looking better!

nvr,
)
if nvr is not None
else (None, None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'd rather do:

if nvr is None:
raise RuntimeException(f"{latest_erratum.id}, returned by Errata tool as an errata for {package_name}, does not have a build for {package_name}")

or something like that - this isn't supposed to happen, if it does happen, we need to figure out why it is happening and what the appropriate handling is here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I agree! It's better to raise an error here rather than a silent pass. will change! 😁

This function used to fetch the Erratum object after it found the previous
erratum. However, we encountered an edge case that the erratum_id from the
erratatools API's response of

<endpoint>/api/v1/product_versions/{RHEL version}/released_builds/{package name}

cound be null in REHL 8. To address this, we decide to make this function just
return the erratum id and build nvr so we can decide whether we should fetch the
Erratum object or not after calling this function.

Also adjust the logic where this function is called.
Adds get_erratum_advisory_url, removes trailing slash from ET_URL,
and updates erratum URL construction across the codebase.
@Jazzcort Jazzcort force-pushed the patch-previous-erratum-logic branch from d6e8d16 to 0fce4ae Compare January 29, 2026 20:14
@Jazzcort Jazzcort requested a review from owtaylor January 29, 2026 20:14
Copy link
Collaborator

@owtaylor owtaylor left a comment

Choose a reason for hiding this comment

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

LGTM!

@TomasTomecek TomasTomecek merged commit 90b25db into packit:main Feb 6, 2026
7 checks passed
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.

3 participants