Skip to content

fix(ai): default analyzer logger to discard when cfg.Logger is nil#177

Closed
HarshParmar029 wants to merge 2 commits into
optiqor:mainfrom
HarshParmar029:fix/nil-logger-analyzer
Closed

fix(ai): default analyzer logger to discard when cfg.Logger is nil#177
HarshParmar029 wants to merge 2 commits into
optiqor:mainfrom
HarshParmar029:fix/nil-logger-analyzer

Conversation

@HarshParmar029

Copy link
Copy Markdown

Fixes #126

Problem

NewAnalyzer did not handle cfg.Logger == nil, causing a nil-pointer
panic on any logging call (e.g. a.logger.Debug(...)).

Fix

Added a nil check in NewAnalyzer. When cfg.Logger is nil, it defaults
to slog.New(slog.NewTextHandler(io.Discard, nil)) — a no-op logger that
produces no output but never panics.

Testing

  • Existing tests pass
  • Added test case for nil logger initialization

@HarshParmar029 HarshParmar029 requested a review from btwshivam as a code owner June 4, 2026 06:53
@github-actions github-actions Bot added level:critical Touches BPF, security, or release surfaces (auto-applied) area/integrations External integrations (sinks, exports, CI) labels Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

🚀 First PR — welcome aboard!

A few things to expect:

  1. CI: every PR runs build + race tests + lint + (eventually) the kernel matrix. If something fails, the log will tell you exactly which gate.
  2. DCO: every commit needs Signed-off-by:git commit -s adds it automatically.
  3. Conventional Commits: PR titles like feat(doctor): add new rule or fix(bpf): handle X. We squash-merge by default.
  4. Review: a maintainer will review within 72 hours. Suggestions are conversations, not orders — push back if something doesn't fit your context.

If you get stuck, reply here or jump to Discussions. We want this PR to land.

…ard logger when cfg.Logger is nil

Signed-off-by: Harsh <hp259369@gmail.com>
@HarshParmar029 HarshParmar029 force-pushed the fix/nil-logger-analyzer branch from 1caaf71 to 800ae4a Compare June 4, 2026 07:25
Signed-off-by: Harsh <hp259369@gmail.com>
@HarshParmar029

Copy link
Copy Markdown
Author

Hi @btwshivam

All CI checks are now passing — including Lint, Build, Test, and Docker.

This PR fixes the nil-pointer panic in NewAnalyzer when cfg.Logger is nil, by defaulting to a no-op slog logger backed by io.Discard.

Would appreciate a review when you get a chance. Happy to make any changes if needed!

@HarshParmar029

Copy link
Copy Markdown
Author

Hi @btwshivam,

Just a gentle follow-up — all CI checks are green, and this fixes the nil logger panic in NewAnalyzer (ref #126).

Happy to address any feedback or make changes. Thanks for your time!

@btwshivam btwshivam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same fix as #162, which also ships a regression test, so we're going with that one. please close this in its favor. thanks for jumping on it.

@btwshivam

Copy link
Copy Markdown
Member

/close

@github-actions github-actions Bot closed this Jun 6, 2026
@btwshivam btwshivam added the gssoc:invalid Does not qualify (low effort, off-spec, regression) label Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/integrations External integrations (sinks, exports, CI) gssoc:invalid Does not qualify (low effort, off-spec, regression) level:critical Touches BPF, security, or release surfaces (auto-applied)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ai): analyzer panics when constructed with nil logger

2 participants