Skip to content

Conversation

@JAVGan
Copy link
Contributor

@JAVGan JAVGan commented Dec 10, 2025

Use ordered diff for get_bundles_latest_version when raising to avoid race condition failures such as:

https://github.com/release-engineering/iib/actions/runs/20110179089/job/57705081674?pr=1276

Summary by Sourcery

Ensure deterministic handling of missing bundle images when resolving latest bundle versions to avoid race-condition-related test failures.

Bug Fixes:

  • Stabilize error handling in get_bundles_latest_version by ordering the reported set of missing bundle images to prevent race-condition-induced test flakiness.

Tests:

  • Adjust expected missing bundle images set in unit tests to match the new deterministic ordering behavior.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 10, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures deterministic behavior and avoids race-condition-related test failures when validating missing bundle images by ordering the computed diff set, and updates the related unit test expectation to match the new deterministic ordering.

File-Level Changes

Change Details Files
Make missing-bundles error message deterministic by ordering the diff set before raising.
  • After computing the set difference of bundles and retrieved versions, sort the difference and cast it back to a set before including it in the IIBError message.
  • Ensure that repeated calls to get_bundles_latest_version produce consistent error messages even when underlying set iteration order might vary.
iib/workers/tasks/build_merge_index_image.py
Adjust unit test expectations to reflect deterministic ordering of missing bundle image identifiers.
  • Reorder the expected missing bundle image strings in the test case to match the new deterministic diff ordering.
  • Maintain the same logical set of expected missing bundles while eliminating order sensitivity that caused flaky test failures.
tests/test_workers/test_tasks/test_build_merge_index_image.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Sorting and then immediately converting back to a set (diff = set(sorted(diff))) does not make the error message deterministic, since sets are unordered; if you need stable ordering in the exception text, keep diff as a list (e.g., diff = sorted(diff) and interpolate that) instead of converting back to a set.
  • The updated test expectation reorders elements inside a set(...), but set literals are inherently order-insensitive, so this change is effectively a no-op for the assertion; consider asserting on a list or the exact error message string if the goal is to verify deterministic ordering.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Sorting and then immediately converting back to a set (`diff = set(sorted(diff))`) does not make the error message deterministic, since sets are unordered; if you need stable ordering in the exception text, keep `diff` as a list (e.g., `diff = sorted(diff)` and interpolate that) instead of converting back to a set.
- The updated test expectation reorders elements inside a `set(...)`, but set literals are inherently order-insensitive, so this change is effectively a no-op for the assertion; consider asserting on a list or the exact error message string if the goal is to verify deterministic ordering.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JAVGan JAVGan changed the title Avoid race condution on unit-tests Avoid race condition on unit-tests Dec 10, 2025
@JAVGan JAVGan force-pushed the qfix branch 3 times, most recently from f7af642 to 6a17c0d Compare December 10, 2025 19:46
Use ordered diff for `get_bundles_latest_version` when raising
to avoid race condition failures such as:

https://github.com/release-engineering/iib/actions/runs/20110179089/job/57705081674?pr=1276

Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
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.

1 participant