Skip to content

in_http: Error in Origin checking logic #2820

@dobesv

Description

@dobesv

I'm seeing this stack trace in the logs occasionally:

 2020-02-07 21:20:18 +0000 [warn]: unexpected error error="undefined method `start_with?' for nil:NilClass"
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:535:in `block in include_cors_allow_origin'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:533:in `each'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:533:in `find'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:533:in `include_cors_allow_origin'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:425:in `on_message_complete'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:308:in `<<'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:308:in `on_read'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin/in_http.rb:242:in `block in on_server_connect'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin_helper/server.rb:611:in `on_read_without_connection'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/cool.io-1.6.0/lib/cool.io/io.rb:123:in `on_readable'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/cool.io-1.6.0/lib/cool.io/io.rb:186:in `on_readable'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/cool.io-1.6.0/lib/cool.io/loop.rb:88:in `run_once'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/cool.io-1.6.0/lib/cool.io/loop.rb:88:in `run'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin_helper/event_loop.rb:93:in `block in start'
  2020-02-07 21:20:18 +0000 [warn]: /fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.9.1/lib/fluent/plugin_helper/thread.rb:78:in `block in thread_create' 

It seems to point to this line as the culprit:

https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/in_http.rb#L535

My best guess is that the value of @origin is nil if the request did not have any Origin header sent. This could probably be fixed by checking if @origin is nil before checking if it matches any of the patterns.

Your Environment

  • Fluentd or td-agent version: 1.9.1
  • Operating system: docker image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions