Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle empty spec for modifyset #2585

Merged
merged 5 commits into from
Feb 22, 2023

Conversation

acpana
Copy link
Contributor

@acpana acpana commented Feb 16, 2023

Fixes #2574

@acpana acpana marked this pull request as ready for review February 16, 2023 02:18
@@ -138,7 +138,7 @@ func MutatorForModifySet(modifySet *mutationsunversioned.ModifySet) (*Mutator, e
return nil, fmt.Errorf("modifyset %s can't change metadata", modifySet.GetName())
}

if path.Nodes[len(path.Nodes)-1].Type() == parser.ListNode {
if len(path.Nodes) > 0 && path.Nodes[len(path.Nodes)-1].Type() == parser.ListNode {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

empty spec leads to empty path which panics. I've added unit tests for all mutators that don't have an empty spec test case to enforce graceful handling of an empty spec.

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2023

Codecov Report

❗ No coverage uploaded for pull request base (master@0ba3c15). Click here to learn what that means.
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2585   +/-   ##
=========================================
  Coverage          ?   53.58%           
=========================================
  Files             ?      120           
  Lines             ?    10634           
  Branches          ?        0           
=========================================
  Hits              ?     5698           
  Misses            ?     4504           
  Partials          ?      432           
Flag Coverage Δ
unittests 53.58% <0.00%> (?)

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

Impacted Files Coverage Δ
.../mutation/mutators/modifyset/modify_set_mutator.go 52.34% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM

@maxsmythe maxsmythe requested review from ritazh and sozercan February 17, 2023 00:51
Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

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

LGTM

@ritazh ritazh merged commit 4ed4663 into open-policy-agent:master Feb 22, 2023
davis-haba pushed a commit to davis-haba/gatekeeper that referenced this pull request Mar 7, 2023
davis-haba pushed a commit to davis-haba/gatekeeper that referenced this pull request Mar 8, 2023
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.

Panic in ModifySet reconciler
4 participants