Closed andsel closed 1 month ago
There's a related bug in this area - if the source field is an empty list, the get()
throws an exception and also causes the pipeline to terminate.
[2024-11-28T13:31:26,832][ERROR][logstash.javapipeline ][main] Pipeline worker error, the pipeline will be stopped {
:pipeline_id=>"main",
:error=>"Index 0 out of bounds for length 0",
:exception=>Java::JavaLang::IndexOutOfBoundsException,
:backtrace=>[
"java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)",
"java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)",
"java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)",
"java.base/java.util.Objects.checkIndex(Objects.java:361)",
"java.base/java.util.ArrayList.get(ArrayList.java:427)",
"org.logstash.filters.geoip.GeoIPFilter.handleEvent(GeoIPFilter.java:153)",
....
Release notes
Avoid to crash pipelines when lookup a database with customised fields.
What does this PR do?
Protect the
handleEvent
method from NPE generated in the MAxMind GeoIP reader library. That NPE happens when fetching data that contains customised attributes, this PR protects from NPE and return a lookup error so that the Event can be tagged with failure.Why is it important/What is the impact to the user?
Permit the user to handle an unexpected error (through event tag) instead of crashing the pipeline, when the data lookup encounter a customised field in the DB.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files (and/or docker env variables)Author's Checklist
How to test this PR locally
Follow the steps listed in #226
Related issues
Use cases
Screenshots
Logs
Before the fix:
After the fix: