Skip to content

fix: add guard for owner_id nil dereference#2138

Merged
MichaelMraka merged 1 commit intoRedHatInsights:masterfrom
dominikvagner:fix-owner-id-nil-deref
Mar 31, 2026
Merged

fix: add guard for owner_id nil dereference#2138
MichaelMraka merged 1 commit intoRedHatInsights:masterfrom
dominikvagner:fix-owner-id-nil-deref

Conversation

@dominikvagner
Copy link
Copy Markdown
Contributor

@dominikvagner dominikvagner commented Mar 31, 2026

Summary

This commit changed OwnerID to a pointer. This adds a guard for that in /listener/upload.go to prevent nil pointer dereferences.

Summary by Sourcery

Bug Fixes:

  • Prevent nil pointer dereference when OwnerID is missing in host system profiles during template assignment.

@dominikvagner dominikvagner requested a review from a team as a code owner March 31, 2026 12:20
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 31, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a nil-check guard and warning log before using SystemProfile.OwnerID in hostTemplate to prevent nil-pointer dereferences when assigning templates.

File-Level Changes

Change Details Files
Guard use of SystemProfile.OwnerID in hostTemplate to avoid nil-pointer dereference and add observability when owner_id is missing.
  • Add early-return check for nil SystemProfile.OwnerID in hostTemplate
  • Log a warning including inventoryID and host.ID when owner_id is missing before template assignment logic
  • Preserve existing template assignment flow when OwnerID is present
listener/upload.go

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

@github-actions
Copy link
Copy Markdown

SC Environment Impact Assessment

Overall Impact:NONE

No SC Environment-specific impacts detected in this PR.

What was checked

This PR was automatically scanned for:

  • Database migrations
  • ClowdApp configuration changes
  • Kessel integration changes
  • AWS service integrations (S3, RDS, ElastiCache)
  • Kafka topic changes
  • Secrets management changes
  • External dependencies

Copy link
Copy Markdown

@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 reviewed your changes and they look great!


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.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.16%. Comparing base (986f68e) to head (d90c4e8).

Files with missing lines Patch % Lines
listener/upload.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2138      +/-   ##
==========================================
- Coverage   59.18%   59.16%   -0.03%     
==========================================
  Files         134      134              
  Lines        8625     8628       +3     
==========================================
  Hits         5105     5105              
- Misses       2985     2987       +2     
- Partials      535      536       +1     
Flag Coverage Δ
unittests 59.16% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelMraka MichaelMraka merged commit 3d32a01 into RedHatInsights:master Mar 31, 2026
9 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