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

Avoid process crash when elasticsearch response is nil #1467

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/es/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *Configuration) NewClient(logger *zap.Logger, metricsFactory metrics.Fac
m.Delete(id)

// log individual errors, note that err might be false and these errors still present
if response.Errors {
if response != nil && response.Errors {
for _, it := range response.Items {
for key, val := range it {
if val.Error != nil {
Expand All @@ -127,7 +127,12 @@ func (c *Configuration) NewClient(logger *zap.Logger, metricsFactory metrics.Fac

sm.Emit(err, time.Since(start.(time.Time)))
if err != nil {
failed := len(response.Failed())
var failed int
if response == nil {
failed = 0
} else {
failed = len(response.Failed())
}
total := len(requests)
logger.Error("Elasticsearch could not process bulk request",
zap.Int("request_count", total),
Expand Down