Skip to content

fix(cli): clarify rule type deletion errors for bundles vs profiles#6310

Open
Aryanburnwal05 wants to merge 1 commit intomindersec:mainfrom
Aryanburnwal05:fix/issue-5306-clear-delete-message
Open

fix(cli): clarify rule type deletion errors for bundles vs profiles#6310
Aryanburnwal05 wants to merge 1 commit intomindersec:mainfrom
Aryanburnwal05:fix/issue-5306-clear-delete-message

Conversation

@Aryanburnwal05
Copy link
Copy Markdown

This change improves the CLI output of minder ruletype delete --all by clearly distinguishing between:

  • Rule types that cannot be deleted because they are part of a bundle
  • Rule types that are referenced by existing profiles

It also improves readability by grouping results and refining CLI formatting.

Additionally, unit tests have been added to validate error categorization and parsing logic.

@Aryanburnwal05 Aryanburnwal05 requested a review from a team as a code owner April 9, 2026 05:30
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

@Aryanburnwal05 Aryanburnwal05 force-pushed the fix/issue-5306-clear-delete-message branch 4 times, most recently from e95a9d9 to 52fca0c Compare April 9, 2026 07:08
Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

Thanks for testing your rule! I think we're likely to add something like #6286 in the future, but this will help keep things stable in the interim.

if err == nil {
return false
}
return strings.Contains(strings.ToLower(err.Error()), "bundle")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What happens if there is a profile named "bundle" or "bundled-policies"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point thanks for calling this out. You are right that matching on a generic substring like "bundle" could lead to false positives in cases where profile names contain similar terms. Since the current server response doesn't expose structured error types for bundle constraints, I opted for a lightweight heuristic here as an interim solution. That said I can tighten this logic to reduce ambiguity (for example, matching more specific phrases), or adjust based on how error contracts evolve (e.g. #6286).

cmd.Println()
cmd.Println("The following rule type(s) are referenced by existing profiles and were not deleted.")
for _, ruleType := range profileBlocked {
cmd.Println("- " + ruleType.Name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This rewrite (diff) seems unnecessary -- can you revert it (and the similar ones below)?

In general, updating extra lines has a few negative effects:

  1. It makes code archaeology (e.g. via "blame" view) harder, because there are more changes to a given line, so it's harder to find the commit which actually changed behavior, rather than simply formatting.
  2. Human reviewers need to look at the changed lines to understand the proposed commit.
    • A lot of extra lines make it more likely that humans will overlook critical changes due to inattention / fatigue
    • Even without that, it simply adds time and effort for human reviewers to assess and dismiss the extra changes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Okay I will correct it.

@Aryanburnwal05 Aryanburnwal05 force-pushed the fix/issue-5306-clear-delete-message branch from 52fca0c to 7b4ed44 Compare April 12, 2026 19:49
fix(cli): clarify rule type deletion errors for bundles vs profilesfix(cli): clarify rule type deletion errors for bundles vs profiles#
@Aryanburnwal05 Aryanburnwal05 force-pushed the fix/issue-5306-clear-delete-message branch from 7b4ed44 to 4990cf6 Compare April 12, 2026 20:29
@Aryanburnwal05
Copy link
Copy Markdown
Author

Hi @evankanderson PTAL

  1. Narrowed bundle error detection to match the specific error string to avoid false positives.
  2. Reverted unrelated formatting/output changes to keep the diff minimal.
  3. Kept the output structure consistent with existing behavior while adding bundle specific messaging.
    If you want me to handle this differently once structured errors are available from the server.

}

rules := []*minderv1.RuleType{
{Id: "rule1", Name: "successful_rule"},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think Id needs to be a pointer to string

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