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

Remove noisy log + prevent panic after parse #1291

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

RebeccaMahany
Copy link
Contributor

Prevents filling logs with error parsing log ingest server url, shipping disabled when shipping is disabled on purpose via sending down an empty URL.

Also prevents a potential panic trying to access parsedUrl.String() when parsedUrl can be nil in the event of an actual parse error.

@RebeccaMahany RebeccaMahany force-pushed the becca/suppress-logship-err branch from dc8f7ac to beb879a Compare August 17, 2023 18:49
directionless
directionless previously approved these changes Aug 17, 2023
Comment on lines 69 to 70
if shouldEnable {
parsedUrl, err := url.Parse(ls.knapsack.LogIngestServerURL())
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised you need this.

https://go.dev/play/p/P2NKDl7t9U_q makes it look like parsing "" will return empty url object. But I guess I'm not sure how to best handle that. So maybe this is good enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will return an empty URL object (and will therefore not panic on parsedUrl.String), but I figured no reason to perform the parse if we don't need to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified this

@RebeccaMahany RebeccaMahany merged commit ce017a3 into kolide:main Aug 18, 2023
@RebeccaMahany RebeccaMahany deleted the becca/suppress-logship-err branch August 18, 2023 13:49
parsedUrl, err := url.Parse(ls.knapsack.LogIngestServerURL())
if err != nil || parsedUrl.String() == "" {
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

thank you for fixing!

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