Skip to content

Add types for rack v3.2 and rack-session v2.1 - #1100

Open
amatsuda wants to merge 4 commits into
ruby:mainfrom
amatsuda:rack-3.2
Open

amatsuda wants to merge 4 commits into
ruby:mainfrom
amatsuda:rack-3.2

Conversation

@amatsuda

Copy link
Copy Markdown
Member

Adds types for rack 3.2 and rack-session 2.1.

Until now, the only rack RBS here was for 2.2, so rbs collection gave it to rack 3 apps too. That RBS declares Rack::Session, which rack 3.0 moved to the rack-session gem, so RBS for rack-session would duplicate those declarations. rack 3.2's RBS doesn't declare Rack::Session, and rack-session's RBS supplies it.

Commits

  1. rack: Copy RBS from 2.2 to 3.2: a plain copy, so that the following commits show the differences.
  2. rack: Update the RBS copied from 2.2 for rack 3.2: removes what rack 3.2 no longer has (Rack::Session, Server, Handler, Lobster, Auth::Digest, Chunked, Utils::HeaderHash, Logger, the old Lint internals, and stale methods and constants), and adds Rack::Headers. The test used Rack::Server, so it now builds an app with Rack::Builder.
  3. rack: Add the API that rack 3.2 adds or changes: Rack::BadRequest and the new errors, RewindableInput::Middleware, MockResponse::Cookie, Response#headers as Rack::Headers, the new Utils and Request methods, and QueryParser's bytesize_limit:/params_limit:. Also removes constants that no longer exist, and cgi from the manifest.
  4. rack-session: Add types for rack-session 2.1: written from the rack-session 2.1.2 source: Cookie with its coders and Encryptor, Pool, Abstract::Persisted/PersistedSecure/ID, SessionHash, and SessionId.

The declarations were checked against rack 3.2.7 and rack-session 2.1.2 for existence and parameters.

The RBS that depends on rack

rack 3 apps now get rack 3.2 and rack-session 2.1, and rack 2 apps still get rack 2.2. These pass bin/test with this change:

  • With rack 3.2 and rack-session 2.1: actionpack 7.2 and 8.1, actionview 8.1, railties 8.1, activerecord 8.1, sinatra 4.0, devise 4.9
  • With rack 3.2: openid_connect 2.3, sentry-ruby 5.2
  • With rack 2.2: actionview 6.0, railties 6.0
  • Also: actionpack 6.0, activesupport 8.1, activemodel 8.1

Without the rack-session commit, the RBS for rack 3 apps would lack Rack::Session, so the commits should be merged together.

🤖 Generated with Claude Code

amatsuda and others added 4 commits October 16, 2026 07:00
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Remove what rack 3.2 no longer has, checked against rack 3.2.7:

- Rack::Session, moved to the rack-session gem in 3.0
- Rack::Server, Rack::Handler, and Rack::Lobster, moved to the rackup
  gem in 3.0
- Rack::Auth::Digest, Rack::Chunked, and Rack::Utils::HeaderHash,
  removed in 3.1, and Rack::Logger, removed in 3.2
- The old Rack::Lint wrappers and checks, which Rack::Lint no longer has
- Methods that no longer exist, like Rack.version, Utils.key_space_limit,
  and Utils.add_cookie_to_header
- HTTP_VERSION, RACK_MULTITHREAD, RACK_MULTIPROCESS, RACK_RUNONCE,
  RACK_HIJACK_IO, and RACK_SESSION_UNPACKED_COOKIE_DATA

Add Rack::Headers, which replaces Utils::HeaderHash, and the constants
added in 3.x. VERSION is now a String. Rack::Builder takes options, and
evaluates its block with the builder as self, and run takes a block.
The test used Rack::Server and Rack::Lobster, so build an app with
Rack::Builder instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Checked against rack 3.2.7:

- Rack::BadRequest, included by the errors raised for bad requests, and
  the new errors QueryParser::QueryLimitError (and ParamsTooDeepError as
  its alias), Multipart::MultipartTotalPartLimitError,
  MissingInputError, EmptyContentError, and BoundaryTooLongError
- Rack::RewindableInput::Middleware and Rack::MockResponse::Cookie,
  which MockResponse#cookies now returns instead of CGI::Cookie
- Response#headers is Rack::Headers, so headers can be set
- Utils.set_cookie_header, delete_set_cookie_header(!),
  forwarded_values, default_query_parser, and the multipart limits,
  Request.ip_filter, forwarded_priority, and
  x_forwarded_proto_priority, Request#form_pairs, Response#no_entity_body?,
  and other new methods
- QueryParser takes bytesize_limit: and params_limit: instead of
  key_space_limit
- Remove the constants that no longer exist, like Cascade::NotFound,
  Utils::ESCAPE_HTML, and the old Multipart regexps
- Remove cgi from the manifest, as the RBS no longer refers to CGI

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
rack 3.0 moved Rack::Session into the rack-session gem, so rack 3 apps
need these with rack 3.2's RBS, which no longer declares Rack::Session.
Written from the rack-session 2.1.2 source, with parameters checked
against it:

- Rack::Session::Cookie with its coders and the Encryptor that encrypts
  the cookie with the :secrets option
- Rack::Session::Pool
- Rack::Session::Abstract::Persisted, PersistedSecure, and ID, with the
  private methods that session stores implement or override, like
  find_session, write_session, and delete_session
- Rack::Session::Abstract::SessionHash, which accepts String and Symbol
  keys
- Rack::Session::SessionId and the RACK_SESSION constants

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown

@amatsuda Thanks for your contribution!

Please follow the instructions below for each change.
See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.

  • /merge: Merge this PR if CI passes

rack-session

This RBS files are newly added.

You can merge this PR immediately if the CI passes.
Just comment /merge to merge this PR.


rack

You changed RBS files for an existing gem.
This gem does not have reviewers. So you can merge this PR immediately if the CI passes.
We recommend you add yourself to the reviewers for this gem.

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 this pull request may close these issues.

1 participant