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

Suppress not found error when applying remove operation #6645

Merged
merged 3 commits into from
Mar 26, 2024

Conversation

0marq
Copy link
Contributor

@0marq 0marq commented Mar 25, 2024

Why the changes in this PR are needed?

Running remove operation on data that is not present should not return an error.

What are the changes in this PR?

In function applyPatches call suppressNotFound function on the output of store.Write if operation is remove

Notes to assist PR review:

Further comments:

bundle/store.go Outdated
@@ -959,6 +959,9 @@ func applyPatches(ctx context.Context, store storage.Store, txn storage.Transact

// apply the patch
if err := store.Write(ctx, txn, op, path, pat.Value); err != nil {
if op == storage.RemoveOp {
return suppressNotFound(err)
Copy link
Member

Choose a reason for hiding this comment

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

As per the spec, the target path MUST exist. Maybe it would be a good idea to update the docs to reflect that. We can update the description of the remove operation to include the line

The target path must exist for the operation to be successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah okk. I reverted the change and updated the doc then.

Copy link

netlify bot commented Mar 26, 2024

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 1f876f9
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/66027182735cac000878f692
😎 Deploy Preview https://deploy-preview-6645--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Mar 26, 2024

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit d347bdb
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/66027964aa940400082a9846
😎 Deploy Preview https://deploy-preview-6645--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Signed-off-by: 0marq <45561584+0marq@users.noreply.github.com>
Update remove description to mention that target path must exist.

Signed-off-by: 0marq <45561584+0marq@users.noreply.github.com>
Signed-off-by: 0marq <45561584+0marq@users.noreply.github.com>
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

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

LGTM

@ashutosh-narkar ashutosh-narkar merged commit 6c08d3f into open-policy-agent:main Mar 26, 2024
26 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.

None yet

2 participants