Skip to content

HMS-10725: support filtering systems by workspace id#2214

Draft
xbhouse wants to merge 1 commit into
RedHatInsights:masterfrom
xbhouse:10725
Draft

HMS-10725: support filtering systems by workspace id#2214
xbhouse wants to merge 1 commit into
RedHatInsights:masterfrom
xbhouse:10725

Conversation

@xbhouse
Copy link
Copy Markdown
Contributor

@xbhouse xbhouse commented May 26, 2026

Adds support for filtering systems by workspace(group) ID. Inventory started using group IDs instead of names, which broke workspace filtering in the Patch systems UI.

Related Inventory ticket for more context: https://redhat.atlassian.net/browse/RHINENG-21928

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Add support for filtering systems by inventory workspace (group) ID in the systems listing APIs.

New Features:

  • Support filtering systems by inventory group ID via the filter[group_id] query parameter in systems list endpoints.

Tests:

  • Add database-backed tests validating single and multiple group ID filters return the expected systems.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 26, 2026

Reviewer's Guide

Adds support for filtering systems by inventory workspace/group ID alongside existing group name filtering, wiring the new filter through request parsing, query construction, tests, and API documentation.

File-Level Changes

Change Details Files
Support filtering systems by inventory group/workspace ID in inventory queries.
  • Extend nested filter mapping to recognize group_id as an inventory group filter key
  • Update inventory query builder to route both group_name and group_id filters through ParseInventoryGroup, switching between ID and name handling based on the filter key
manager/controllers/utils.go
Add tests to validate filtering by inventory group/workspace ID including multi-ID scenarios.
  • Add DB-backed test that filters systems by a single group_id value and asserts the expected system IDs are returned
  • Add DB-backed test that filters systems by multiple group_id values and asserts the expected number of systems is returned
manager/controllers/utils_test.go
Expose the new group_id filter parameter in the systems list API documentation.
  • Document filter[group_id] as a query parameter for all systems list endpoints in controller annotations
  • Propagate the new filter[group_id] parameter into the generated OpenAPI v3 specification
manager/controllers/systems.go
docs/v3/openapi.json

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

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.26%. Comparing base (6c5b053) to head (7881164).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2214      +/-   ##
==========================================
+ Coverage   59.23%   59.26%   +0.02%     
==========================================
  Files         137      137              
  Lines        8795     8801       +6     
==========================================
+ Hits         5210     5216       +6     
  Misses       3037     3037              
  Partials      548      548              
Flag Coverage Δ
unittests 59.26% <100.00%> (+0.02%) ⬆️

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.

@xbhouse xbhouse marked this pull request as ready for review May 26, 2026 20:02
@xbhouse xbhouse requested a review from a team as a code owner May 26, 2026 20:02
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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="manager/controllers/utils.go" line_range="394-401" />
<code_context>
-	if strings.Contains(key, "group_name") {
+	if strings.Contains(key, "group_name") || strings.Contains(key, "group_id") {
 		groups := []string{}
 		for _, v := range values {
-			name := v
-			group, err := utils.ParseInventoryGroup(nil, &name)
+			var group string
+			var err error
+			if strings.Contains(key, "group_id") {
+				group, err = utils.ParseInventoryGroup(&v, nil)
+			} else {
+				group, err = utils.ParseInventoryGroup(nil, &v)
+			}
 			if err != nil {
 				// couldn't marshal inventory group to json
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid taking the address of the `range` loop variable `v` when calling `ParseInventoryGroup`.

This change reintroduces the Go `range`-variable-address pitfall: `&v` is reused across iterations. It only works as long as `ParseInventoryGroup` never stores or uses the pointer asynchronously. To keep this future-proof, copy `v` into a new local (e.g. `id := v`, `name := v`) and pass the address of that local in both branches.
</issue_to_address>

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.

Comment thread manager/controllers/utils.go
@xbhouse
Copy link
Copy Markdown
Contributor Author

xbhouse commented May 27, 2026

this may not be needed anymore, inventory is going to revert the breaking changes. i'll move this to draft until the revert to make sure

@xbhouse xbhouse marked this pull request as draft May 27, 2026 14:18
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