consumer, scheduler: support testing dist-git PRs (#104) #143

Merged
adamwill merged 1 commit from schedule-distgit-prs into main 2026-07-11 00:57:12 +00:00
Owner

This makes it possible to request openQA tests for dist-git PRs.
Anyone (for now) can comment "/openqa test" on a dist-git PR,
and if the consumer is configured to listen on the appropriate
topics, it should schedule update tests (always the full set, for
now) on the scratch build associated with the PR. If the scratch
build is complete when the comment is added, the tests should be
scheduled immediately; if not, the tests will be scheduled when
we get a message indicating a scratch build has completed for the
PR. We also automatically test any subsequent scratch builds for
the same PR when they complete.

As part of this, we move the openqa_hostname and openqa_baseurl
definitions from consumer config to fedora_openqa config. They
are always the same for all consumers in real-world use, so it
doesn't really make sense to require them to be set for every
consumer.

Signed-off-by: Adam Williamson awilliam@redhat.com

This makes it possible to request openQA tests for dist-git PRs. Anyone (for now) can comment "/openqa test" on a dist-git PR, and if the consumer is configured to listen on the appropriate topics, it should schedule update tests (always the full set, for now) on the scratch build associated with the PR. If the scratch build is complete when the comment is added, the tests should be scheduled immediately; if not, the tests will be scheduled when we get a message indicating a scratch build has completed for the PR. We also automatically test any subsequent scratch builds for the same PR when they complete. As part of this, we move the openqa_hostname and openqa_baseurl definitions from consumer config to fedora_openqa config. They are always the same for all consumers in real-world use, so it doesn't really make sense to require them to be set for every consumer. Signed-off-by: Adam Williamson <awilliam@redhat.com>
consumer, scheduler: support testing dist-git PRs (#104)
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m14s
AI Code Review / ai-review (pull_request_target) Successful in 19s
ae3aac2bd3
This makes it possible to request openQA tests for dist-git PRs.
Anyone (for now) can comment "/openqa test" on a dist-git PR,
and if the consumer is configured to listen on the appropriate
topics, it should schedule update tests (always the full set, for
now) on the scratch build associated with the PR. If the scratch
build is complete when the comment is added, the tests should be
scheduled immediately; if not, the tests will be scheduled when
we get a message indicating a scratch build has completed for the
PR. We also automatically test any subsequent scratch builds for
the same PR when they complete.

As part of this, we move the openqa_hostname and openqa_baseurl
definitions from consumer config to fedora_openqa config. They
are always the same for all consumers in real-world use, so it
doesn't really make sense to require them to be set for every
consumer.

Signed-off-by: Adam Williamson <awilliam@redhat.com>

AI Code Review

Detailed Code Review

The PR introduces functionality to automatically trigger and report on openQA tests for dist-git pull requests, which is a significant workflow enhancement. Moving the openQA URLs to a centralized configuration is a good refactor. However, there are a few potential issues related to dictionary key handling, robust string matching, and URL construction that should be addressed to ensure stability. Specifically, dictionary accesses like comment["comment"] on potentially varied Pagure payloads should be done carefully to avoid KeyError, and splitting arbitrary URLs or checking for specific branches requires more robust error handling.

📂 File Reviews

📄 `src/fedora_openqa/consumer.py` - Introduces logic for scheduling openQA jobs based on Pagure PR comments and flags, and includes a new reporter for pushing results back to dist-git.
  • Major [Bug]: Missing dictionary key check for comment["comment"]. If a comment dictionary doesn't contain the 'comment' key, this will raise a KeyError.
    • Suggestion: Use .get("comment") instead of direct bracket access.
if not comment.get("comment") == "/openqa test":
    self.logger.debug("Not a comment requesting openQA tests")
    return
  • Major [Bug]: Same issue with missing dictionary key check for comment["comment"] in _consume_pr_flag list comprehension.
    • Suggestion: Use .get("comment") in the any() generator expression.
if not any(comment.get("comment") == "/openqa test" for comment in pr.get("comments", [])):
    return
  • Minor [Logic]: The logic not f" {branch} " in flag["username"] might be brittle if Pagure/Packit changes how they format usernames in scratch build flags.

    • Suggestion: Consider a more robust matching strategy, or at least document this dependency on Packit's flag naming convention.
  • Minor [Bug]: _version_from_branch is defined outside a class but accepts self as the first argument, behaving like a method. However, it's called as _version_from_branch(self, body).

    • Suggestion: If it doesn't need to be part of the class, remove self and just pass logger (or self.logger), or move it inside the class as a method.
def _version_from_branch(logger, body):
    # ...
    logger.debug("PR branch %s appears to not be a Fedora mainline release branch", branch)
    # ...

# Call site:
version, branch = _version_from_branch(self.logger, body)
📄 `src/fedora_openqa/schedule.py` - Updates the `jobs_from_update` function to correctly parse task IDs from PR strings.
  • Minor [Logic]: update.startswith("PR-") could fail if update is a list, since strings have startswith but lists do not. The check isinstance(update, list) or update.startswith("PR-") works because Python short-circuits, but if update is neither a list nor a string, it will throw an AttributeError.
    • Suggestion: Check if update is a string before calling startswith.
if isinstance(update, list) or (isinstance(update, str) and update.startswith("PR-")):

Summary

  • Overall Assessment: The changes successfully implement dist-git testing capabilities, though a few potential bugs with dictionary accesses and function signatures should be fixed to prevent runtime exceptions.
  • Priority Issues:
    • Fix KeyError risks by using .get("comment") instead of ["comment"] on Pagure comment objects.
    • Refactor _version_from_branch to either be a proper class method or pass the logger directly, rather than passing self to a standalone function.
    • Ensure update.startswith("PR-") in schedule.py is protected by a string type check to prevent AttributeError.
  • Minor Suggestions:
    • Make Packit username string matching more robust if possible.

🤖 AI Code Review | Generated with ai-code-review | Model: gemini-3.1-pro-preview

⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.

## AI Code Review ### Detailed Code Review The PR introduces functionality to automatically trigger and report on openQA tests for dist-git pull requests, which is a significant workflow enhancement. Moving the openQA URLs to a centralized configuration is a good refactor. However, there are a few potential issues related to dictionary key handling, robust string matching, and URL construction that should be addressed to ensure stability. Specifically, dictionary accesses like `comment["comment"]` on potentially varied Pagure payloads should be done carefully to avoid KeyError, and splitting arbitrary URLs or checking for specific branches requires more robust error handling. #### 📂 File Reviews <details> <summary><strong>📄 `src/fedora_openqa/consumer.py`</strong> - Introduces logic for scheduling openQA jobs based on Pagure PR comments and flags, and includes a new reporter for pushing results back to dist-git.</summary> - **Major** [Bug]: Missing dictionary key check for `comment["comment"]`. If a comment dictionary doesn't contain the 'comment' key, this will raise a KeyError. - *Suggestion:* Use `.get("comment")` instead of direct bracket access. ```` if not comment.get("comment") == "/openqa test": self.logger.debug("Not a comment requesting openQA tests") return ```` - **Major** [Bug]: Same issue with missing dictionary key check for `comment["comment"]` in `_consume_pr_flag` list comprehension. - *Suggestion:* Use `.get("comment")` in the `any()` generator expression. ```` if not any(comment.get("comment") == "/openqa test" for comment in pr.get("comments", [])): return ```` - **Minor** [Logic]: The logic `not f" {branch} " in flag["username"]` might be brittle if Pagure/Packit changes how they format usernames in scratch build flags. - *Suggestion:* Consider a more robust matching strategy, or at least document this dependency on Packit's flag naming convention. - **Minor** [Bug]: `_version_from_branch` is defined outside a class but accepts `self` as the first argument, behaving like a method. However, it's called as `_version_from_branch(self, body)`. - *Suggestion:* If it doesn't need to be part of the class, remove `self` and just pass `logger` (or `self.logger`), or move it inside the class as a method. ```` def _version_from_branch(logger, body): # ... logger.debug("PR branch %s appears to not be a Fedora mainline release branch", branch) # ... # Call site: version, branch = _version_from_branch(self.logger, body) ```` </details> <details> <summary><strong>📄 `src/fedora_openqa/schedule.py`</strong> - Updates the `jobs_from_update` function to correctly parse task IDs from PR strings.</summary> - **Minor** [Logic]: `update.startswith("PR-")` could fail if `update` is a list, since strings have `startswith` but lists do not. The check `isinstance(update, list) or update.startswith("PR-")` works because Python short-circuits, but if `update` is neither a list nor a string, it will throw an AttributeError. - *Suggestion:* Check if `update` is a string before calling `startswith`. ```` if isinstance(update, list) or (isinstance(update, str) and update.startswith("PR-")): ```` </details> ### ✅ Summary - **Overall Assessment:** The changes successfully implement dist-git testing capabilities, though a few potential bugs with dictionary accesses and function signatures should be fixed to prevent runtime exceptions. - **Priority Issues:** - Fix `KeyError` risks by using `.get("comment")` instead of `["comment"]` on Pagure comment objects. - Refactor `_version_from_branch` to either be a proper class method or pass the logger directly, rather than passing `self` to a standalone function. - Ensure `update.startswith("PR-")` in `schedule.py` is protected by a string type check to prevent `AttributeError`. - **Minor Suggestions:** - Make Packit username string matching more robust if possible. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) | **Model:** `gemini-3.1-pro-preview` ⚠️ *AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.*
adamwill force-pushed schedule-distgit-prs from ae3aac2bd3
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m14s
AI Code Review / ai-review (pull_request_target) Successful in 19s
to a488ba9912
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m14s
2026-07-03 21:57:38 +00:00
Compare
adamwill force-pushed schedule-distgit-prs from a488ba9912
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m14s
to 869b8518d8
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m14s
AI Code Review / ai-review (pull_request_target) Successful in 15s
2026-07-03 22:02:38 +00:00
Compare
Author
Owner

Fixed some of the AI review stuff.

Fixed some of the AI review stuff.

AI Code Review

Detailed Code Review

The PR introduces functionality to trigger openQA tests for dist-git PRs using a comment command (/openqa test). The implementation correctly relocates openqa_hostname and openqa_baseurl to the global fedora_openqa config. The logic correctly handles both immediate triggering and queuing for asynchronous build completions. However, the security model around who can trigger tests remains completely open, posing a denial of service or resource exhaustion risk. There are also potential edge cases with string manipulations, API responses, and exception handling.

Summary

  • Overall Assessment: The changes generally work as intended based on the logic provided, but an open authorization model for test triggering presents a security/resource risk that should be addressed before deployment.
  • Priority Issues:
    • Unrestricted access to the /openqa test command could lead to resource exhaustion if malicious or accidental users trigger builds continuously.
    • No retry logic or robust error handling for external requests (like setting PR flags via requests.post), which can fail silently except for a log message.
    • String parsing for task IDs assumes precise formats without sufficient validation, which could throw IndexError.
  • Minor Suggestions:
    • Use URL query building tools instead of manual string concatenation for overviewurl.
    • Centralize the parsing of BUILD strings into a helper function to avoid repeated brittle split operations.
    • Implement a timeout on external API requests using the requests library.

🤖 AI Code Review | Generated with ai-code-review | Model: gemini-3.1-pro-preview

⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.

## AI Code Review ### Detailed Code Review The PR introduces functionality to trigger openQA tests for dist-git PRs using a comment command (`/openqa test`). The implementation correctly relocates `openqa_hostname` and `openqa_baseurl` to the global `fedora_openqa` config. The logic correctly handles both immediate triggering and queuing for asynchronous build completions. However, the security model around who can trigger tests remains completely open, posing a denial of service or resource exhaustion risk. There are also potential edge cases with string manipulations, API responses, and exception handling. ### ✅ Summary - **Overall Assessment:** The changes generally work as intended based on the logic provided, but an open authorization model for test triggering presents a security/resource risk that should be addressed before deployment. - **Priority Issues:** - Unrestricted access to the `/openqa test` command could lead to resource exhaustion if malicious or accidental users trigger builds continuously. - No retry logic or robust error handling for external requests (like setting PR flags via `requests.post`), which can fail silently except for a log message. - String parsing for task IDs assumes precise formats without sufficient validation, which could throw `IndexError`. - **Minor Suggestions:** - Use URL query building tools instead of manual string concatenation for `overviewurl`. - Centralize the parsing of `BUILD` strings into a helper function to avoid repeated brittle `split` operations. - Implement a timeout on external API requests using the `requests` library. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) | **Model:** `gemini-3.1-pro-preview` ⚠️ *AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.*
adamwill force-pushed schedule-distgit-prs from 869b8518d8
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m14s
AI Code Review / ai-review (pull_request_target) Successful in 15s
to f5aac5ca5e
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 51s
AI Code Review / ai-review (pull_request_target) Successful in 17s
CI via Tox / tox (pull_request) Successful in 2m12s
2026-07-03 22:48:49 +00:00
Compare
Author
Owner

Added retries and timeout to the requests stuff, and used urlencode for overviewurl.

Added retries and timeout to the requests stuff, and used urlencode for overviewurl.

AI Code Review

Detailed Code Review

The author implemented the logic to schedule openQA tests for dist-git PRs based on incoming fedmsg (Pagure) comments and flag updates, migrating configuration parameters for shared usage. Retries and basic URL encoding were applied. The logic accurately monitors '/openqa test' PR comments, retrieves scratch build tasks, schedules the appropriate openQA tests, and reports success, failure, or error back to the dist-git PR flag. Overall, the approach is architecturally sound and integrates neatly into the established consumer frameworks.

However, a logic issue exists when fetching properties from nested dictionaries where defaults are expected to be an empty string but are missing .get fallback in secondary indexing (e.g., prid construction). There is also a missing input validation for branch format matching in the mainline checker, but since it is handled softly it mostly just returns an empty string. The PR ID parsing splits on '-' with maxsplit 2, which could fail if the repository string itself has extra hyphens in unexpected structures.

Summary

  • Overall Assessment: The changes successfully add dist-git PR support with centralized openQA configuration. A few minor edge cases with data parsing could cause exceptions on unexpected payload structures.
  • Minor Suggestions:
    • Safeguard prid construction in _consume_pr_comment and _consume_pr_flag against pr.get("project", {}) being None, as get() defaults to {} but might return None if the key exists with a null value.
    • Handle potential ValueError in build.replace("-NOREPORT", "").split("-", 2) if the BUILD string unexpectedly does not contain exactly two hyphens after substitution.

🤖 AI Code Review | Generated with ai-code-review | Model: gemini-3.1-pro-preview

⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.

## AI Code Review ### Detailed Code Review The author implemented the logic to schedule openQA tests for dist-git PRs based on incoming fedmsg (Pagure) comments and flag updates, migrating configuration parameters for shared usage. Retries and basic URL encoding were applied. The logic accurately monitors '/openqa test' PR comments, retrieves scratch build tasks, schedules the appropriate openQA tests, and reports success, failure, or error back to the dist-git PR flag. Overall, the approach is architecturally sound and integrates neatly into the established consumer frameworks. However, a logic issue exists when fetching properties from nested dictionaries where defaults are expected to be an empty string but are missing `.get` fallback in secondary indexing (e.g., `prid` construction). There is also a missing input validation for branch format matching in the mainline checker, but since it is handled softly it mostly just returns an empty string. The PR ID parsing splits on '-' with maxsplit 2, which could fail if the repository string itself has extra hyphens in unexpected structures. ### ✅ Summary - **Overall Assessment:** The changes successfully add dist-git PR support with centralized openQA configuration. A few minor edge cases with data parsing could cause exceptions on unexpected payload structures. - **Minor Suggestions:** - Safeguard `prid` construction in `_consume_pr_comment` and `_consume_pr_flag` against `pr.get("project", {})` being None, as `get()` defaults to `{}` but might return `None` if the key exists with a null value. - Handle potential `ValueError` in `build.replace("-NOREPORT", "").split("-", 2)` if the `BUILD` string unexpectedly does not contain exactly two hyphens after substitution. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) | **Model:** `gemini-3.1-pro-preview` ⚠️ *AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.*
Author
Owner

I love the smell of "exceptions on unexpected payload structures" in the morning. Makes me feel alive.

I love the smell of "exceptions on unexpected payload structures" in the morning. Makes me feel alive.
Author
Owner

@lruzicka wdyt?

@lruzicka wdyt?
adamwill force-pushed schedule-distgit-prs from f5aac5ca5e
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 51s
AI Code Review / ai-review (pull_request_target) Successful in 17s
CI via Tox / tox (pull_request) Successful in 2m12s
to 177e6093e4
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m19s
2026-07-04 00:02:07 +00:00
Compare
Author
Owner

cleaned up the tests a bit with some of my beloved parametrization.

cleaned up the tests a bit with some of my beloved parametrization.
schedule only appropriate flavors based on critpath groups
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m12s
c1ac713c25
Signed-off-by: Adam Williamson <awilliam@redhat.com>
adamwill force-pushed schedule-distgit-prs from c1ac713c25
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 52s
CI via Tox / tox (pull_request) Successful in 2m12s
to 06dd07fe02
Some checks failed
CI via Tox / checkwiki (pull_request) Successful in 49s
CI via Tox / tox (pull_request) Failing after 2m11s
2026-07-08 00:18:47 +00:00
Compare
adamwill force-pushed schedule-distgit-prs from 06dd07fe02
Some checks failed
CI via Tox / checkwiki (pull_request) Successful in 49s
CI via Tox / tox (pull_request) Failing after 2m11s
to 76c9942bef
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 50s
CI via Tox / tox (pull_request) Successful in 2m9s
2026-07-08 00:43:54 +00:00
Compare
adamwill force-pushed schedule-distgit-prs from 76c9942bef
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 50s
CI via Tox / tox (pull_request) Successful in 2m9s
to ee4a4f5f18
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 50s
CI via Tox / tox (pull_request) Successful in 2m8s
2026-07-08 18:34:42 +00:00
Compare
adamwill force-pushed schedule-distgit-prs from ee4a4f5f18
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 50s
CI via Tox / tox (pull_request) Successful in 2m8s
to 09be49a7fa
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 50s
CI via Tox / tox (pull_request) Successful in 2m7s
2026-07-08 18:37:27 +00:00
Compare
Author
Owner

I've done some fixes to this for current Rawhide, and to fix the test on GNOME (there was a needle tag mismatch). More tests running now.

I've done some fixes to this for current Rawhide, and to fix the test on GNOME (there was a needle tag mismatch). More tests running now.
adamwill force-pushed schedule-distgit-prs from 09be49a7fa
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 50s
CI via Tox / tox (pull_request) Successful in 2m7s
to e7df0f5214
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 51s
CI via Tox / tox (pull_request) Successful in 2m11s
AI Code Review / ai-review (pull_request_target) Successful in 42s
2026-07-11 00:38:21 +00:00
Compare

AI Code Review

Detailed Code Review

The PR introduces functional additions to trigger openQA testing for dist-git PRs via message bus consumption. The author has proactively addressed several stability concerns, such as configuring a requests session with robust retry logic and correctly isolating configuration. However, the implementation is currently vulnerable to message processing hangs due to a missing HTTP timeout on a secondary API call, and there are a couple of fragile data extraction patterns from the Pagure message payload that could lead to unhandled exceptions (and thus consumer crashes) under edge cases.

📂 File Reviews

📄 `src/fedora_openqa/consumer.py` - Introduces logic to consume PR comments and flag updates, scheduling openQA tests for dist-git PRs.
  • Critical [Bug]: The SESSION.get() call to Bodhi for critpath components is missing a timeout. If the Bodhi service hangs or becomes unresponsive, the fedora-messaging consumer will block indefinitely, preventing the consumption of any further messages.
    • Suggestion: Add an explicit timeout to the request, consistent with the other SESSION requests in this file.
critpath = SESSION.get("https://bodhi.fedoraproject.org/get_critpath_components", timeout=60).json()
  • Major [Bug]: Extracting the last comment using pr.get("comments", [{}])[-1] is vulnerable to an IndexError. If the Pagure API payload includes an explicitly empty list ("comments": []), pr.get() will return [], and [-1] will raise an IndexError, causing the consumer to crash for that message.
    • Suggestion: Safely extract the comments list and verify it is not empty before accessing the last element.
comments = pr.get("comments") or []
if not comments:
    return
comment = comments[-1]
  • Minor [Logic]: In _consume_pr_flag, the fallback for pr.get("comments") is an empty dictionary ({}). While iterating over an empty dictionary is safe, if the field ever contained a populated dictionary, iterating over it would yield string keys, leading to an AttributeError when comment.get("comment", "") is called. It is safer and more semantically correct to default to an empty list.
    • Suggestion: Change the default fallback from {} to [].
if not any(comment.get("comment", "") == "/openqa test" for comment in pr.get("comments", [])):
  • Minor [Bug]: In _jobs_from_flag, if the flag payload explicitly sets the username to None, flag.get("username", "") will return None (not ""). The subsequent in operator string check will raise a TypeError.
    • Suggestion: Ensure the username resolves to a string before using the in operator.
if not f" {branch} " in (flag.get("username") or ""):

Summary

  • Overall Assessment: The core logic and messaging interactions are well-structured, but critical missing network timeouts and potential unhandled exceptions during JSON payload parsing must be fixed to ensure the message consumer remains robust and stable.
  • Priority Issues:
    • Missing timeout on the Bodhi critpath API request, risking message queue blockages.
    • Potential IndexError when extracting PR comments if the payload explicitly provides an empty list.
    • Potential TypeError on flag.get('username') if the API explicitly returns None.
  • Minor Suggestions:
    • Use empty list [] instead of empty dict {} as the default fallback when getting the 'comments' array.

🤖 AI Code Review | Generated with ai-code-review | Model: gemini-3.1-pro-preview

⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.

## AI Code Review ### Detailed Code Review The PR introduces functional additions to trigger openQA testing for dist-git PRs via message bus consumption. The author has proactively addressed several stability concerns, such as configuring a requests session with robust retry logic and correctly isolating configuration. However, the implementation is currently vulnerable to message processing hangs due to a missing HTTP timeout on a secondary API call, and there are a couple of fragile data extraction patterns from the Pagure message payload that could lead to unhandled exceptions (and thus consumer crashes) under edge cases. #### 📂 File Reviews <details> <summary><strong>📄 `src/fedora_openqa/consumer.py`</strong> - Introduces logic to consume PR comments and flag updates, scheduling openQA tests for dist-git PRs.</summary> - **Critical** [Bug]: The `SESSION.get()` call to Bodhi for critpath components is missing a `timeout`. If the Bodhi service hangs or becomes unresponsive, the fedora-messaging consumer will block indefinitely, preventing the consumption of any further messages. - *Suggestion:* Add an explicit timeout to the request, consistent with the other `SESSION` requests in this file. ```` critpath = SESSION.get("https://bodhi.fedoraproject.org/get_critpath_components", timeout=60).json() ```` - **Major** [Bug]: Extracting the last comment using `pr.get("comments", [{}])[-1]` is vulnerable to an `IndexError`. If the Pagure API payload includes an explicitly empty list (`"comments": []`), `pr.get()` will return `[]`, and `[-1]` will raise an `IndexError`, causing the consumer to crash for that message. - *Suggestion:* Safely extract the comments list and verify it is not empty before accessing the last element. ```` comments = pr.get("comments") or [] if not comments: return comment = comments[-1] ```` - **Minor** [Logic]: In `_consume_pr_flag`, the fallback for `pr.get("comments")` is an empty dictionary (`{}`). While iterating over an empty dictionary is safe, if the field ever contained a populated dictionary, iterating over it would yield string keys, leading to an `AttributeError` when `comment.get("comment", "")` is called. It is safer and more semantically correct to default to an empty list. - *Suggestion:* Change the default fallback from `{}` to `[]`. ```` if not any(comment.get("comment", "") == "/openqa test" for comment in pr.get("comments", [])): ```` - **Minor** [Bug]: In `_jobs_from_flag`, if the flag payload explicitly sets the `username` to `None`, `flag.get("username", "")` will return `None` (not `""`). The subsequent `in` operator string check will raise a `TypeError`. - *Suggestion:* Ensure the username resolves to a string before using the `in` operator. ```` if not f" {branch} " in (flag.get("username") or ""): ```` </details> ### ✅ Summary - **Overall Assessment:** The core logic and messaging interactions are well-structured, but critical missing network timeouts and potential unhandled exceptions during JSON payload parsing must be fixed to ensure the message consumer remains robust and stable. - **Priority Issues:** - Missing timeout on the Bodhi critpath API request, risking message queue blockages. - Potential IndexError when extracting PR comments if the payload explicitly provides an empty list. - Potential TypeError on flag.get('username') if the API explicitly returns None. - **Minor Suggestions:** - Use empty list [] instead of empty dict {} as the default fallback when getting the 'comments' array. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) | **Model:** `gemini-3.1-pro-preview` ⚠️ *AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.*
adamwill force-pushed schedule-distgit-prs from e7df0f5214
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 51s
CI via Tox / tox (pull_request) Successful in 2m11s
AI Code Review / ai-review (pull_request_target) Successful in 42s
to ac5a56f41b
All checks were successful
CI via Tox / checkwiki (pull_request) Successful in 49s
CI via Tox / tox (pull_request) Successful in 2m9s
2026-07-11 00:56:41 +00:00
Compare
Author
Owner

Timeout added. The other things aren't worth worrying about in context.

Timeout added. The other things aren't worth worrying about in context.
adamwill deleted branch schedule-distgit-prs 2026-07-11 00:57:12 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quality/fedora_openqa!143
No description provided.