graylog2-server icon indicating copy to clipboard operation
graylog2-server copied to clipboard

string_array_add pipeline function: Add handling for null elements argument

Open danotorrey opened this issue 1 year ago • 0 comments

Description

Add handling for condition when the elements string_array_add pipeline function receives a null value, such as when a non-existent field (e.g.$message.field_does_not_exist) is passed to it.

Now, the function correctly returns the supplied value

Motivation and Context

Fixes https://github.com/Graylog2/graylog-plugin-enterprise/issues/7262

How Has This Been Tested?

To manually test this create a pipeline rule with the following rule (supplying the function a null value), and use the Rule simulator below, to ensure that the correct [ "test1", "test2" ] value is returned, and that the error mentioned in the issue does not occur.

rule "test"
when
    true
then
    let t = string_array_add (
        elements: $message.null_field,
        value: [ "test1", "test2" ]
        );
        
    set_field ( field: "_test", value: t );
end

image

Screenshots (if appropriate):

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Refactoring (non-breaking change)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ ] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.

danotorrey avatar May 24 '24 16:05 danotorrey