Skip to content

undefined method split for 2:Integer when updating falcon #2

@renatolond

Description

@renatolond

Hey!

I'm not sure if this belongs here or in falcon, so sorry if it's better to be in Falcon instead. When I tried upgrading falcon to 0.42.x, I had an issue because I write an Integer header which used to be auto-converted and now it's not anymore.
Here's the backtrace:

 2.16s    error: Protocol::Rack::Adapter::Rack2 [oid=0x1860] [ec=0x1810] [pid=78517] [2022-08-30 11:04:33 +0200]
               |   NoMethodError: undefined method `split' for 2:Integer
               |
               |                                                        value.split("\n").each do |value|
               |                                                             ^^^^^^
               |   → /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-rack-0.2.2/lib/protocol/rack/adapter/rack2.rb:112 in `block in wrap_headers'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/utils.rb:449 in `block in each'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/utils.rb:448 in `each'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/utils.rb:448 in `each'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-rack-0.2.2/lib/protocol/rack/adapter/rack2.rb:106 in `wrap_headers'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-rack-0.2.2/lib/protocol/rack/adapter/rack2.rb:84 in `call'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-http-0.23.10/lib/protocol/http/middleware.rb:50 in `call'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-rack-0.2.2/lib/protocol/rack/rewindable.rb:58 in `call'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-http-0.23.10/lib/protocol/http/middleware.rb:50 in `call'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-http-0.23.10/lib/protocol/http/content_encoding.rb:46 in `call'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/protocol-http-0.23.10/lib/protocol/http/middleware.rb:50 in `call'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/async-http-0.59.2/lib/async/http/server.rb:67 in `block in accept'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/async-http-0.59.2/lib/async/http/protocol/http1/server.rb:62 in `each'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/async-http-0.59.2/lib/async/http/server.rb:56 in `accept'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/async-io-1.34.0/lib/async/io/server.rb:32 in `block in accept_each'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/async-io-1.34.0/lib/async/io/socket.rb:73 in `block in accept'
               |     /home/renatolond/.rvm/rubies/ruby-3.1.2-jemalloc/lib/ruby/gems/3.1.0/gems/async-1.30.3/lib/async/task.rb:261 in `block in make_fiber'

I use grape for my API, here's an example code that has the issue

# frozen_string_literal: true

# A sample Gemfile
source "https://rubygems.org"

gem "grape"
gem "falcon"
#!/usr/bin/env falcon --verbose serve -c
# frozen_string_literal: true

# Save this as `config.ru`, make it executable and then run it (or run falcon serve by hand)

# Middleware that responds to incoming requests:
require 'grape'
class MyApp < Grape::API
  get "/" do
    header "my-header", 123
    "ok"
  end
end

run MyApp

My tests did not catch the issue, rack-test accepts the integer header and I'm assuming casts it to a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions