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: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check #1599

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented Jan 10, 2025

Description

Fix: Prevent nil errors in setupLog.Error to ensure proper logging
Closes; #1566
Closes: #1556

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@camilamacedo86 camilamacedo86 requested a review from a team as a code owner January 10, 2025 20:45
Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit c597f22
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/6781882610b5df0008a81037
😎 Deploy Preview https://deploy-preview-1599--olmv1.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.

@camilamacedo86 camilamacedo86 changed the title 🐛 Fix error message 🐛 Fix: Prevent nil errors in setupLog.Error to ensure proper logging and add sanity check Jan 10, 2025
Add a check to be called in the verify where we can add adtional
sanity checks to ensure the qiality of the project
Copy link
Member

Choose a reason for hiding this comment

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

Oh I like this!

Nit: I'd probably name this hack/ci/extra_linters.sh
Also nit: Is there a way to define the rules and messages such that they are setup as a list of pairs, and then we go ahead and write a loop to iterate and run each of them?

Lastly, I kinda wonder if there's already a generic regex-based linter built into golangci-lint that we could add custom rules 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.

Good points, I will try to check them out.

Copy link
Member

Choose a reason for hiding this comment

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

We may also want to look into writing custom analyzers in Go using golang.org/x/tools/go/analysis. As is, if we have a variable name for a logger that is not setupLog, we'll miss it.

I assume an analyzer could find all logr.Logger.Error() method usage where the first parameter is nil.

Copy link
Member

Choose a reason for hiding this comment

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

But now I'm getting really picky :)

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 think the idea of the custom analyse is nice
I will try it out.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 66.68%. Comparing base (75bb73e) to head (c597f22).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
catalogd/cmd/catalogd/main.go 0.00% 2 Missing ⚠️
cmd/operator-controller/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1599   +/-   ##
=======================================
  Coverage   66.68%   66.68%           
=======================================
  Files          57       57           
  Lines        4584     4584           
=======================================
  Hits         3057     3057           
  Misses       1302     1302           
  Partials      225      225           
Flag Coverage Δ
e2e 52.63% <0.00%> (-0.09%) ⬇️
unit 53.62% <0.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Fix issues with logging flag validations
2 participants