Skip to content

NoMethodError when a header value is not a string #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
danielwestendorf opened this issue May 8, 2025 · 1 comment · May be fixed by #82
Open

NoMethodError when a header value is not a string #81

danielwestendorf opened this issue May 8, 2025 · 1 comment · May be fixed by #82

Comments

@danielwestendorf
Copy link

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.

@danielwestendorf
Copy link
Author

This originates here with the default policy Split that requires a String.

@danielwestendorf danielwestendorf linked a pull request May 8, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant