Commit 860c901
committed
fix: prevent nil pointer panic in EventEmitter
Add nil check for Kubernetes client in EmitMessage to prevent panic when
client is uninitialized. This fixes a crash that occurs during error
handling in GitLab provider when 401 errors are encountered.
The EventEmitter now gracefully handles three nil scenarios:
- nil repo: skips event creation, continues logging
- nil logger: skips logging, continues event creation
- nil client: skips event creation, continues logging
Added comprehensive test coverage for nil client scenario to match
existing tests for nil repo and nil logger cases.
Fixes crash: runtime error: invalid memory address or nil pointer
dereference at pkg/events/emit.go:36
Jira: https://issues.redhat.com/browse/SRVKP-8910
Assisted-by: Claude-Sonnet-4.5 (via Claude Code)
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>1 parent b4d37f6 commit 860c901
2 files changed
+28
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
85 | 102 | | |
86 | 103 | | |
87 | 104 | | |
| |||
97 | 114 | | |
98 | 115 | | |
99 | 116 | | |
100 | | - | |
101 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
102 | 127 | | |
103 | 128 | | |
104 | 129 | | |
| |||
0 commit comments