Skip to content

Inline mustermann-grape into Grape::Router::MustermannPattern - #2755

Merged
dblock merged 2 commits into
masterfrom
refactor/inline-mustermann-grape
Jun 12, 2026
Merged

dblock merged 2 commits into
masterfrom
refactor/inline-mustermann-grape

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

Why

mustermann-grape is a ~40-line Mustermann::AST::Pattern subclass that defines Grape's path syntax (:param, *splat, {name} / {+splat}, ( ) optionals, |, and an Integer digit-only constraint). In practice it exists only for Grape — and it has already grown Grape-specific: the Integer constraint reaches into Grape's own params option.

param_type = pattern&.options&.dig(:params, param_name, :type)
constraint = param_type == 'Integer' ? /\d/ : '[^/?#.]'

Keeping it as a separate gem means a two-step release for any syntax change (cut a mustermann-grape release, then bump Grape's ~> 1.1.0 pin), plus its own CI and versioning — a lot of ceremony for 40 lines only Grape uses. Grape also always instantiated the class directly (Mustermann::Grape.new), never through the type: :grape registry.

What

  • Move the grammar into Grape as Grape::Router::MustermannPattern (MIT attribution to the original authors — namusyaka, Konstantin Haase, Daniel Doubrovkine — preserved), and instantiate it directly from Grape::Router::Pattern.
  • Depend on mustermann directly instead of mustermann-grape.
  • Drop the register :grape call — Grape never used the registry, and not squatting a global Mustermann type keeps the inlined grammar a private Grape detail.

This is not a deep dependency reduction: the grammar extends Mustermann::AST::Pattern, so the mustermann core dependency stays. The graph just collapses from grape → mustermann-grape → mustermann to grape → mustermann, and Grape owns the 40 lines it was already coupled to. The win is maintenance: pattern-syntax changes become a single PR instead of a cross-gem release dance.

Compatibility

One behavioral change: the pattern class is no longer registered as type: :grape. Apps that called Mustermann.new(_, type: :grape) and relied on Grape pulling in mustermann-grape transitively should add gem 'mustermann-grape' to their Gemfile directly. Documented in UPGRADING.md.

Validation

  • bundle install now resolves without mustermann-grape (only mustermann 4.0.0) — Grape is self-sufficient.
  • Full suite 2,316 examples, 0 failures; RuboCop clean.
  • Integer-constraint behavior verified: /api/:id matches 42, rejects foo.

🤖 Generated with Claude Code

@ericproulx
ericproulx force-pushed the refactor/inline-mustermann-grape branch from 8d60f9c to 2b7d16c Compare June 1, 2026 13:39
@github-actions

github-actions Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@ericproulx
ericproulx marked this pull request as draft June 1, 2026 13:56
@ericproulx
ericproulx force-pushed the refactor/inline-mustermann-grape branch from 2b7d16c to a969b46 Compare June 1, 2026 13:56
mustermann-grape is a ~40-line Mustermann::AST::Pattern subclass that exists
only for Grape's path syntax, and it had already grown Grape-specific: the
Integer constraint reads Grape's own `params` option. Maintaining it as a
separate gem meant a two-step release for every syntax tweak (cut a
mustermann-grape release, then bump Grape's pin) plus its own CI/versioning.

Move the grammar into Grape as Grape::Router::MustermannPattern (attribution to
the original authors preserved), depend on `mustermann` directly, and
instantiate it directly from Grape::Router::Pattern as Grape always did. The
`mustermann` core dependency is unchanged; the graph collapses from
grape -> mustermann-grape -> mustermann to grape -> mustermann.

The class is no longer registered as a Mustermann `type: :grape` (Grape never
used the registry). Apps that called `Mustermann.new(_, type: :grape)` relying
on Grape pulling in mustermann-grape transitively should depend on it directly;
see UPGRADING.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ericproulx
ericproulx force-pushed the refactor/inline-mustermann-grape branch from a969b46 to f3be4cd Compare June 1, 2026 14:01
ericproulx added a commit that referenced this pull request Jun 1, 2026
Grape requires Ruby >= 3.3 and activesupport >= 7.2 (Rails 7.2+), but several
dependency floors still advertised support for much older releases that Grape
no longer tests:

- rack            >= 2     -> >= 2.2.4  (minimum rack across Rails 7.2 and above)
- zeitwerk        (none)   -> >= 2.7    (where zeitwerk moved to Ruby >= 3.2)
- dry-configurable (none)  -> >= 1.4    (first release requiring Ruby >= 3.3)
- dry-types       >= 1.1   -> >= 1.9    (current line, Ruby >= 3.2)

Resolved versions are unchanged (rack 3.2.6, zeitwerk 2.8.2, dry-configurable
1.4.0, dry-types 1.9.1); only the floors change. mustermann is left to #2755.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ericproulx
ericproulx marked this pull request as ready for review June 1, 2026 15:09
@dblock

dblock commented Jun 2, 2026

Copy link
Copy Markdown
Member

Makes sense, let's just check-in with @namusyaka on whether there was a reason to have a separate gem for this?

@dblock
dblock merged commit 1477dc5 into master Jun 12, 2026
65 checks passed
@dblock
dblock deleted the refactor/inline-mustermann-grape branch June 12, 2026 23:58
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops the `if index` guard in `RouteBuckets::Bucket#match`:
each alternative in a bucket's union is its route's named group, so a
match of the union always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param: the
  qualifying params are neither stored nor read, and what is missing is
  still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param: the
  qualifying params are neither stored nor read, and what is missing is
  still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 22, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param: the
  qualifying params are neither stored nor read, and what is missing is
  still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param: the
  qualifying params are neither stored nor read, and what is missing is
  still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` with `coerce_with` given as an object
  responding to `parse`: its `parse` method does the coercion.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param: the
  qualifying params are neither stored nor read, and what is missing is
  still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param: the
  qualifying params are neither stored nor read, and what is missing is
  still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param: the
  qualifying params are neither stored nor read, and what is missing is
  still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- `Validators::Base#validate!` passing over an empty element of an
  optional array scope nested past the one-level shortcut.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param and for
  an array param at the root (`Validators::Base#validate_elements!`):
  nothing is tracked, and what is missing is still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- `Validators::Base#validate!` passing over an empty element of an
  optional array scope nested past the one-level shortcut.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param and for
  an array param at the root (`Validators::Base#validate_elements!`):
  nothing is tracked, and what is missing is still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- `Validators::Base#validate!` passing over an empty element of an
  optional array scope nested past the one-level shortcut.
- `Validators::ExceptValuesValidator`: a Proc taking an argument is
  rejected at definition, a non-Hash array element is left to its own
  type check, a Proc handing back no list accepts any value, and an
  excluded nil rejects an explicit null without also rejecting a
  required param that was left out.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param and for
  an array param at the root (`Validators::Base#validate_elements!`):
  nothing is tracked, and what is missing is still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- `Validators::Base#validate!` passing over an empty element of an
  optional array scope nested past the one-level shortcut.
- `Validators::ExceptValuesValidator`: a Proc taking an argument is
  rejected at definition, a non-Hash array element is left to its own
  type check, a Proc handing back no list accepts any value, and an
  excluded nil rejects an explicit null without also rejecting a
  required param that was left out.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Validators::HashElementsValidator#validate_param!`'s
`hash_like?` guard: the validator is registered not required, and Base
only asks such a validator about params that are a Hash.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param and for
  an array param at the root (`Validators::Base#validate_elements!`):
  nothing is tracked, and what is missing is still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- `Validators::Base#validate!` passing over an empty element of an
  optional array scope nested past the one-level shortcut.
- `Validators::ExceptValuesValidator`: a Proc taking an argument is
  rejected at definition, a non-Hash array element is left to its own
  type check, a Proc handing back no list accepts any value, and an
  excluded nil rejects an explicit null without also rejecting a
  required param that was left out.
- `Validators::OneofValidator` accepting an optional param sent as an
  explicit null rather than left out.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Validators::HashElementsValidator#validate_param!`'s
`hash_like?` guard: the validator is registered not required, and Base
only asks such a validator about params that are a Hash.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param and for
  an array param at the root (`Validators::Base#validate_elements!`):
  nothing is tracked, and what is missing is still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- `Validators::Base#validate!` passing over an empty element of an
  optional array scope nested past the one-level shortcut.
- `Validators::ExceptValuesValidator`: a Proc taking an argument is
  rejected at definition, a non-Hash array element is left to its own
  type check, a Proc handing back no list accepts any value, and an
  excluded nil rejects an explicit null without also rejecting a
  required param that was left out.
- `Validators::ValuesValidator` accepting any value when a `values:`
  Proc hands back no list, unlike an empty one.
- `Validators::OneofValidator` accepting an optional param sent as an
  explicit null rather than left out.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Validators::HashElementsValidator#validate_param!`'s
`hash_like?` guard: the validator is registered not required, and Base
only asks such a validator about params that are a Hash.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ericproulx added a commit that referenced this pull request Sep 23, 2026
…DSL readers (#2983)

Covers branches no spec reached:

- `Exceptions::Base#compose_message` skipping a step whose translation
  is blank (a step missing from the locale was already covered).
- `Middleware::Error` answering its failsafe response on an env without
  `rack.errors`, which Rack::Lint rejects and rack-test cannot send.
- `Middleware::Formatter` passing through a request that announces a
  body but carries none: no `rack.input` (optional since Rack 3.1), or
  a chunked input that reads empty.
- `Router::BaseRoute` with a route naming a param twice: its captures
  cannot be read off the union match, so it has none of its own, in the
  router's union or in any bucket, and Mustermann answers every
  position.
- `Router::RouteBuckets#segment_key` with a path that has fewer
  segments than the position the buckets split on: it names no bucket,
  and the request goes to the fallback.
- `Grape::Testing`'s `reset_before_each` on an endpoint class no hook
  was ever registered on. The suite's `after` hook only reached that
  depending on example order.
- `ParamsScope` validators run on their own, outside the request's
  ParamScopeTracker, for a `given` scope within an array param and for
  an array param at the root (`Validators::Base#validate_elements!`):
  nothing is tracked, and what is missing is still reported.
- `optional :all, using:` with a field whose options are nil: the field
  is left out, as `requires :none` already does.
- `Types::ArrayCoercer` built strict, for an Array member type in
  `types:` with `coerce_with`: the custom method's result is only
  type-checked, so a blank String is not coerced into an empty Array.
- `Types::CustomTypeCoercer` with a callable given as `type:` alongside
  `coerce_with`, as its docs describe: the callable checks the coerced
  value.
- `Types::MultipleTypeCoercer` and `Types::VariantCollectionCoercer`
  with `coerce_with` given as an object responding to `parse`: its
  `parse` method does the coercion.
- `ValidationsSpec#guess_coerce_type` skipping an empty `values:` list
  for a bare `type: Array` and guessing the member type from
  `except_values:` instead.
- `Validators::Base#validate!` passing over an empty element of an
  optional array scope nested past the one-level shortcut.
- `Validators::ExceptValuesValidator`: a Proc taking an argument is
  rejected at definition, a non-Hash array element is left to its own
  type check, a Proc handing back no list accepts any value, and an
  excluded nil rejects an explicit null without also rejecting a
  required param that was left out.
- `Validators::ValuesValidator` accepting any value when a `values:`
  Proc hands back no list, unlike an empty one.
- `Validators::OneofValidator` accepting an optional param sent as an
  explicit null rather than left out.
- The `format`, `default_error_formatter` and `default_error_status`
  readers, `format` raising for a format with no content type, and
  `format` accepting one registered with `content_type`.

Drops two safe navigations whose nil branch could never be covered:

- `DSL::Routing#version`'s on `@versions`, which is assigned just above.
- `Router::Pattern::Path#uses_path_versioning?`'s on `version_options`,
  which the `version` DSL always sets together with `version`.

It also drops `ParamsScope#should_validate?`'s `return true if
@parent.nil?`: past the `@independent` return, the scope or one above it
is a `given` scope, which is always nested.

It also drops `Validators::HashElementsValidator#validate_param!`'s
`hash_like?` guard: the validator is registered not required, and Base
only asks such a validator about params that are a Hash.

It also drops `Util::MediaType.match?`'s blank-subtype check: the
vendor regexp is anchored on `vnd.`, so a blank subtype already fails
it (pinned by a new `application/` example).

It also drops `Util::Translation#translate`'s check for a caller's
`default:` after a miss: I18n answers any given default with that
default, never with the private MISSING sentinel, so only a call without
one gets past it.

It also drops the guard for a union match that sets no route's group,
in `RouteBuckets::Bucket#match` and in `Router#transaction` and
`Router#neighbour_match?`: each alternative in these unions is its
route's named group, so a match always sets one of them.
- `Router::MustermannPattern`'s on `pattern` and `pattern.options`.
  `Mustermann::Pattern.new` always sets the options, and the parser
  runs without a pattern only for Mustermann's `except:` option, which
  Grape never passes. Both came in with mustermann-grape (#2755), a
  registered type that could be built with `except:`.

Folds #2984 and #2985.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants