← Back to Issue

Split keyword arguments off #args on Rails.application.middleware entries

From uloza+hey@proton.me · original ↗ · unsubscribe

Middleware entries now expose keyword arguments through a new #kwargs accessor. #args previously bundled kwargs as a trailing hash inside the positional array (via Hash.ruby2_keywords_hash). It now returns positional arguments only.


Refactor `MiddlewareStack::Middleware` off `Hash.ruby2_keywords_hash` by kamipo · Pull Request #58420 · rails/rails · GitHub

Skip to content

Sign in

Appearance settings

Search/

Sign in

Sign up

Appearance settings

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

Uh oh!

There was an error while loading. Please reload this page.

rails / rails Public

Additional navigation options

Refactor MiddlewareStack::Middleware off Hash.ruby2_keywords_hash - #58420

#58420

Merged

kamipo merged 1 commit into

rails:mainrails/rails:mainfrom

kamipo:refactor_actionpack_middleware_kwargskamipo/rails:refactor_actionpack_middleware_kwargsCopy head branch name to clipboard

Aug 9, 2026

ConversationCommits1 (1)ChecksFiles changed

Merged

##

Refactor MiddlewareStack::Middleware off Hash.ruby2_keywords_hash#58420

kamipo merged 1 commit into

rails:mainrails/rails:mainfrom

kamipo:refactor_actionpack_middleware_kwargskamipo/rails:refactor_actionpack_middleware_kwargsCopy head branch name to clipboard

Conversation

@kamipo

###

@kamipokamipo commented Aug 8, 2026

Copy link

Copy Markdown

Member

Follow-up to #58239. Hash.ruby2_keywords_hash is scheduled for deprecation (https://bugs.ruby-lang.org/issues/22205); libraries that only support Ruby 3.0+ shouldn’t depend on it.

Middleware (and its ActionController subclass) now store positional args and keyword args separately (@args / @kwargs) instead of bundling Hash.ruby2_keywords_hash(kwargs) into @args, and #build dispatches with klass.new(app, *args, **kwargs, &block).

Middleware and InstrumentationProxy are also marked :nodoc:. Users interact with the stack through use / insert / etc. and, for instrumentation, subscribe to process_middleware.action_dispatch (documented in the Active Support Instrumentation guide). Neither class is intended to be constructed directly, so their internal structure doesn’t belong in the API docs even though iterating Rails.application.middleware still exposes Middleware#args / #kwargs for debugging.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions@kamipo

[Refactor `MiddlewareStack::Middleware` off `Hash.ruby2_keywords_hash`](/rails/rails/pull/58420/commits/26b88332672781769fec3279d9c504f5ee9fffde "Refactor `MiddlewareStack::Middleware` off `Hash.ruby2_keywords_hash` Follow-up to #58239. `Hash.ruby2_keywords_hash` is scheduled for deprecation (https://bugs.ruby-lang.org/issues/22205); libraries that only support Ruby 3.0+ shouldn't depend on it. `Middleware` (and its `ActionController` subclass) now store positional args and keyword args separately (`@args` / `@kwargs`) instead of bundling `Hash.ruby2_keywords_hash(kwargs)` into `@args`, and `#build` dispatches with `klass.new(app, *args, **kwargs, &block)`. `Middleware` and `InstrumentationProxy` are also marked `:nodoc:`. Users interact with the stack through `use` / `insert` / etc. and, for instrumentation, subscribe to `process_middleware.action_dispatch` (documented in the Active Support Instrumentation guide). Neither class is intended to be constructed directly, so their internal structure doesn't belong in the API docs even though iterating `Rails.application.middleware` still exposes `Middleware#args` / `#kwargs` for debugging.") …

[26b8833](/rails/rails/pull/58420/commits/26b88332672781769fec3279d9c504f5ee9fffde)

Follow-up to rails#58239. `Hash.ruby2_keywords_hash` is scheduled for deprecation (https://bugs.ruby-lang.org/issues/22205); libraries that only support Ruby 3.0+ shouldn’t depend on it.

`Middleware` (and its `ActionController` subclass) now store positional args and keyword args separately (`@args` / `@kwargs`) instead of bundling `Hash.ruby2_keywords_hash(kwargs)` into `@args`, and `#build` dispatches with `klass.new(app, *args, **kwargs, &block)`.

`Middleware` and `InstrumentationProxy` are also marked `:nodoc:`. Users interact with the stack through `use` / `insert` / etc. and, for instrumentation, subscribe to `process_middleware.action_dispatch` (documented in the Active Support Instrumentation guide). Neither class is intended to be constructed directly, so their internal structure doesn’t belong in the API docs even though iterating `Rails.application.middleware` still exposes `Middleware#args` / `#kwargs` for debugging.

@github-actions github-actions Bot added actionpack railties labels Aug 8, 2026

Hide details View details

@kamipo

kamipo merged commit 653804d into rails:main Aug 9, 2026

5 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kamipo

kamipo deleted the refactor_actionpack_middleware_kwargs branch August 9, 2026 08:11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

### Reviewers

No reviews

Assignees

No one assigned

Labels

actionpack railties

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@kamipo

Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

© 2026 GitHub, Inc.

You can’t perform that action at this time.

Highlights & notes

    Notes