You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#14044 was introduced to fix a long-standing issue where setting a field whose name includes characters that are reserved in the FieldReference syntax ([ and ]) had undefined behaviour that resulted in pipeline crashes or the silent truncation of the field name. However, this does not work when these characters are in the middle of the fieldname, rather than at the beginning:
A simple test:
context 'with map value whose keys have embedded FieldReference-special characters' do
let(:event) { LogStash::Event.new }
let(:value) { {"this[field]" => "okay"} }
it 'sets the value correctly' do
event.set('this[mixed]field', value.dup)
expect(event.get('this[mixed]field')).to eq(value)
end
end
Results in the following:
1) LogStash::Event#set with map value whose keys have embedded FieldReference-special characters sets the value correctly
Failure/Error: event.set('this[mixed]field', value.dup)
RuntimeError:
Invalid FieldReference: `this[mixed]field`
# ./logstash-core/spec/logstash/event_spec.rb:209:in `block in <main>'
# ./spec/spec_helper.rb:66:in `block in <main>'
# ./logstash-core/lib/logstash/util.rb:43:in `set_thread_name'
# ./spec/spec_helper.rb:65:in `block in <main>'
# ./spec/spec_helper.rb:58:in `block in <main>'
# ./vendor/bundle/jruby/2.6.0/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block in <main>'
# ./vendor/bundle/jruby/2.6.0/gems/logstash-devutils-2.4.0-java/lib/logstash/devutils/rspec/spec_helper.rb:61:in `block in <main>'
# ./lib/bootstrap/rspec.rb:36:in `<main>'
Note that using the event constructor instead of the set method does not result in the same error:
it 'accepts maps whose keys contain embedded FieldReference-special characters' do
e = LogStash::Event.new({"nested" => {"this[embedded]legal" => "okay"}, "n[0]" => "bene"})
expect(e.get('nested')).to eq({"this[embedded]legal" => "okay"})
expect(e.to_hash).to include("n[0]" => "bene")
end
runs without error.
The text was updated successfully, but these errors were encountered:
#14044 was introduced to fix a long-standing issue where setting a field whose name includes characters that are reserved in the FieldReference syntax (
[
and]
) had undefined behaviour that resulted in pipeline crashes or the silent truncation of the field name. However, this does not work when these characters are in the middle of the fieldname, rather than at the beginning:A simple test:
Results in the following:
Note that using the event constructor instead of the set method does not result in the same error:
runs without error.
The text was updated successfully, but these errors were encountered: