Skip to content

NoMethodError when a header value is not a string #81

Open
@danielwestendorf

Description

@danielwestendorf

My API endpoints have been 503-ing w/my falcon served rails application. Once identified (my exception handling didn't catch this, and I wasn't monitoring for 5XX anomalies 😿) I was able to reproduce locally.

web              |  46.1s     warn: Async::Task: Reading HTTP/1.1 requests for Async::HTTP::Protocol::HTTP1::Server. [oid=0x15c10] [ec=0x2ed8] [pid=78930] [2025-05-08 13:38:20 -0600]
web              |                | Task may have ended with unhandled exception.
web              |                |   NoMethodError: undefined method 'split' for an instance of Integer (NoMethodError)
web              |                |
web              |                |                                             super(value.split(COMMA))
web              |                |                                                        ^^^^^^
web              |                |   → /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/header/split.rb:21 in 'Protocol::HTTP::Header::Split#initialize'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/headers.rb:332 in 'Array.new'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/headers.rb:332 in 'Protocol::HTTP::Headers#merge_into'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/headers.rb:353 in 'block in Protocol::HTTP::Headers#to_h'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/headers.rb:352 in 'Array#each'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/headers.rb:352 in 'Enumerable#inject'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/headers.rb:352 in 'Protocol::HTTP::Headers#to_h'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/headers.rb:345 in 'Protocol::HTTP::Headers#[]'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/content_encoding.rb:43 in 'Protocol::HTTP::ContentEncoding#call'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/protocol-http-0.49.0/lib/protocol/http/middleware.rb:53 in 'Protocol::HTTP::Middleware#call'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/falcon-0.51.1/lib/falcon/server.rb:66 in 'Falcon::Server#call'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/async-http-0.88.0/lib/async/http/server.rb:58 in 'block in Async::HTTP::Server#accept'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/async-http-0.88.0/lib/async/http/protocol/http1/server.rb:71 in 'Async::HTTP::Protocol::HTTP1::Server#each'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/async-http-0.88.0/lib/async/http/server.rb:50 in 'Async::HTTP::Server#accept'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/falcon-0.51.1/lib/falcon/server.rb:57 in 'Falcon::Server#accept'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/io-endpoint-0.15.2/lib/io/endpoint/wrapper.rb:216 in 'block (2 levels) in IO::Endpoint::Wrapper#accept'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/async-2.23.1/lib/async/task.rb:200 in 'block in Async::Task#run'
web              |                |     /Users/dwestendorf/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/async-2.23.1/lib/async/task.rb:438 in 'block in Async::Task#schedule'

The application code causing this is

headers["X-RateLimit-Limit"] = api_limit.max

where the value is an integer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions