{"record":{"id":"e9d2e898608dbb0d","repo":"ruby-grape/grape","slug":"unknown-using-for-versioner-strategy","errorCode":null,"errorMessage":"unknown :using for versioner: %{strategy}","messagePattern":"unknown :using for versioner: %(.+?)","errorType":"exception","errorClass":"Grape::Exceptions::InvalidVersionerOption","httpStatus":null,"severity":"error","filePath":"lib/grape/middleware/versioner.rb","lineNumber":21,"sourceCode":"# Versioners set env['api.version'] when a version is defined on an API and\n# on the requests. The current methods for determining version are:\n#\n#   :header - version from HTTP Accept header.\n#   :accept_version_header - version from HTTP Accept-Version header\n#   :path   - version from uri. e.g. /v1/resource\n#   :param  - version from uri query string, e.g. /v1/resource?apiver=v1\n# See individual classes for details.\nmodule Grape\n  module Middleware\n    module Versioner\n      extend Grape::Util::Registry\n\n      module_function\n\n      # @param strategy [Symbol] :path, :header, :accept_version_header or :param\n      # @return a middleware class based on strategy\n      def using(strategy)\n        raise Grape::Exceptions::InvalidVersionerOption, strategy unless registry.key?(strategy)\n\n        registry[strategy]\n      end\n    end\n  end\nend\n","sourceCodeStart":3,"sourceCodeEnd":28,"githubUrl":"https://github.com/ruby-grape/grape/blob/22d7975629846a3c0c7bd2b34e140a7a1b4af8f6/lib/grape/middleware/versioner.rb#L3-L28","documentation":"`version 'v1', using: :strategy` selects the versioning middleware from a registry populated by Grape::Middleware::Versioner subclasses. Only :path, :header, :accept_version_header, and :param are registered; anything else raises Grape::Exceptions::InvalidVersionerOption ('unknown :using for versioner: X') when the API class is mounted.","triggerScenarios":"`version 'v1', using: :path_version` or `using: :query`. Passing a string `using: 'header'`-style typo like `:headers`. A custom strategy class that was never registered via Grape::Middleware::Versioner.register.","commonSituations":"Typos when first adding API versioning. Copying config between apps where a custom versioner middleware existed. Renaming strategies during upgrades and missing a call site.","solutions":["Use one of the four supported symbols: :path, :header, :accept_version_header, or :param.","For a custom strategy, subclass Grape::Middleware::Versioner::Base (auto-registered by its demodulized, underscored name) or call Grape::Middleware::Versioner.register with your class and pass that short name."],"exampleFix":"# before\nversion 'v1', using: :path_version # raises InvalidVersionerOption\n\n# after\nversion 'v1', using: :path\nmount MyAPI => '/api'","handlingStrategy":"validation","validationCode":"VERSIONERS = %i[path header accept_version_header param].freeze\n\nraise ArgumentError, \"using: must be one of #{VERSIONERS.join(', ')}\" unless VERSIONERS.include?(strategy)\nversion 'v1', using: strategy","typeGuard":"def valid_versioner?(sym) = %i[path header accept_version_header param].include?(sym)","tryCatchPattern":null,"preventionTips":["Centralize versioning config in one constant used by every API class.","Spec that mounts the root of the API catches InvalidVersionerOption at load time.","For custom strategies, subclass Versioner::Base so registration is automatic, and spec the short name resolves."],"tags":["grape","versioning","middleware","configuration"],"backgroundTag":"invalid-versioning-strategy","analyzedSha":"22d7975629846a3c0c7bd2b34e140a7a1b4af8f6","analyzedAt":"2026-08-21T17:03:54.627Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}