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

silencing the SDK to ensure it does not panic #4314

Merged
merged 2 commits into from
Feb 2, 2022

Conversation

damienjburks
Copy link
Contributor

Addresses issue #4303

Copy link
Contributor

@srenatus srenatus 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 picking this up! Would you mind adding a test to assert that the empty config works OK now where it panicked before?

sdk/options.go Outdated
bs, err := ioutil.ReadAll(o.Config)
if err != nil {
return err
var bs = []byte("{}")
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] This should be the same as

Suggested change
var bs = []byte("{}")
bs := []byte("{}")

where I think the bs := variant is a bit more consistent with the overall code style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the recommended adjustments and added a test case.

sdk/options.go Outdated
var bs = []byte("{}")

if o.Config == nil {
o.config = bs
Copy link
Contributor

@johanfylling johanfylling Feb 1, 2022

Choose a reason for hiding this comment

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

Also a nit: I think we could inline the value of bs here, as there is really no need for it in the outer scope: o.config = []byte("{}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually like this one better. Making that adjustment now

srenatus
srenatus previously approved these changes Feb 2, 2022
Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

LGTM, one final nitpick

sdk/opa_test.go Outdated Show resolved Hide resolved
@srenatus
Copy link
Contributor

srenatus commented Feb 2, 2022

If you wouldn't mind, could you please also squash the commits? A short message including

Fixes #4303

would be great, too.

@damienjburks
Copy link
Contributor Author

@srenatus Everything looks good to me. Please check and confirm when you get a chance.

Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@srenatus srenatus merged commit 0c14834 into open-policy-agent:main Feb 2, 2022
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