Skip to content

fix: allow system to be registered with broken insights-client#3700

Closed
jlocash wants to merge 3 commits intocandlepin:mainfrom
jlocash:jlocash/cct-1574
Closed

fix: allow system to be registered with broken insights-client#3700
jlocash wants to merge 3 commits intocandlepin:mainfrom
jlocash:jlocash/cct-1574

Conversation

@jlocash
Copy link

@jlocash jlocash commented Feb 27, 2026

  • Card ID: CCT-1574

* Card ID: CCT-1574

Signed-off-by: Joshua Locash <jlocash@redhat.com>
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR broadens the error handling when importing the insights_client constants so that any exception during import is treated as a missing/disabled insights client, allowing system registration to proceed even when the insights client is broken in non-ImportError ways.

Flow diagram for insights_client import error handling

flowchart TD
    A[Start module rhsmlib.facts.insights] --> B[Try import insights_client.constants as insights_constants]
    B -->|Import succeeds| C[insights_constants set to imported constants]
    B -->|Any Exception raised| D[insights_constants set to None]
    C --> E[Rest of module uses insights_constants]
    D --> E[Rest of module treats insights as missing/disabled]
Loading

File-Level Changes

Change Details Files
Broaden exception handling around insights_client constants import to tolerate broken insights-client states.
  • Change the import guard to catch any Exception instead of only ImportError when importing insights_client.constants.
  • Ensure insights_constants is set to None whenever the import fails for any reason, signaling the rest of the code to behave as if insights is unavailable.
src/rhsmlib/facts/insights.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

@jlocash
Copy link
Author

jlocash commented Feb 27, 2026

/packit build

@jlocash jlocash marked this pull request as ready for review March 6, 2026 14:03
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 - I've left some high level feedback:

  • Catching a broad Exception during the insights_client import risks masking unrelated runtime errors; consider narrowing this to the specific exception(s) raised by the broken client or adding a comment explaining why a broad catch is required.
  • When insights_constants is set to None due to a failed import, it might be helpful to log a warning or debug message so that operators can distinguish between a truly absent client and other import-time failures.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Catching a broad `Exception` during the `insights_client` import risks masking unrelated runtime errors; consider narrowing this to the specific exception(s) raised by the broken client or adding a comment explaining why a broad catch is required.
- When `insights_constants` is set to `None` due to a failed import, it might be helpful to log a warning or debug message so that operators can distinguish between a truly absent client and other import-time failures.

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.

@jlocash jlocash closed this Mar 6, 2026
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