ruby-grape/grape · warning

`Grape::Router.normalize_path` is deprecated. Use `Grape::Ut

Error message

`Grape::Router.normalize_path` is deprecated. Use `Grape::Util::PathNormalizer.call` instead.

What it means

`Grape::Router.normalize_path` moved to `Grape::Util::PathNormalizer.call`. The class-method shim remains for compatibility: it warns via `Grape.deprecator` and delegates to the new implementation, but it will be removed in a future release.

Source

Thrown at lib/grape/router.rb:7

# frozen_string_literal: true

module Grape
  class Router
    # @deprecated Use {Grape::Util::PathNormalizer.call} instead.
    def self.normalize_path(path)
      Grape.deprecator.warn(
        '`Grape::Router.normalize_path` is deprecated. Use `Grape::Util::PathNormalizer.call` instead.'
      )
      Grape::Util::PathNormalizer.call(path)
    end

    def initialize
      @neutral_map = []
      @neutral_regexes = []
      # Plain hashes with no auto-vivifying default: a lookup for an HTTP method
      # that has no routes must not insert a key. `compile!` freezes both maps,
      # so request-time reads never mutate shared state (see #match? / #rotation).
      @map = {}
      @optimized_map = {}
    end

    def compile!
      return if @compiled

View on GitHub (pinned to 22d7975629)

Solutions

  1. Replace the call with `Grape::Util::PathNormalizer.call(path)`
  2. If you support multiple Grape versions, branch on the constant: use PathNormalizer when defined, else the old method

Example fix

# before
Grape::Router.normalize_path('/foo//bar/')

# after
Grape::Util::PathNormalizer.call('/foo//bar/')
Defensive patterns

Strategy: fallback

Validate before calling

def normalize_path(path)
  if defined?(Grape::Util::PathNormalizer)
    Grape::Util::PathNormalizer.call(path)
  else
    Grape::Router.normalize_path(path) # older Grape
  end
end

Prevention

When it happens

Trigger: Calling `Grape::Router.normalize_path('/foo//bar/')` in initializers, specs, or helper gems that pre-normalize endpoint paths before registering them with Grape.

Common situations: Code that reached into Grape internals to normalize paths; third-party mounting gems or copied snippets calling the old class method after an upgrade.

Related errors


AI-assisted analysis of ruby-grape/grape@22d7975629 (2026-08-21). Data as JSON: /api/errors/4d43f1bc95f27ced. Report an issue: GitHub.