{"record":{"id":"362f16f076f19fb1","repo":"ruby-grape/grape","slug":"passing-a-positional-options-hash-to-method-nam-362f16","errorCode":null,"errorMessage":"Passing a positional options Hash to `#{method_name}` is deprecated. Pass keyword arguments instead.","messagePattern":"Passing a positional options Hash to `#(.+?)` is deprecated\\. Pass keyword arguments instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/grape/middleware/auth/dsl.rb","lineNumber":33,"sourceCode":"        # Add HTTP Basic authorization to the API.\n        #\n        # @param options [Hash] a hash of options\n        # @option options [String] :realm \"API Authorization\" the HTTP Basic realm\n        def http_basic(*legacy_options, **options, &)\n          options = merge_legacy_auth_options(:http_basic, legacy_options, options)\n          options[:realm] ||= 'API Authorization'\n          auth(:http_basic, **options, &)\n        end\n\n        private\n\n        # @deprecated Passing a positional options Hash is deprecated; pass\n        #   keyword arguments instead. Kept so downstream callers keep working\n        #   through the deprecation cycle.\n        def merge_legacy_auth_options(method_name, legacy_options, options)\n          return options if legacy_options.empty?\n\n          Grape.deprecator.warn(\"Passing a positional options Hash to `#{method_name}` is deprecated. Pass keyword arguments instead.\")\n          legacy_options.first.merge(options)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":15,"sourceCodeEnd":40,"githubUrl":"https://github.com/ruby-grape/grape/blob/22d7975629846a3c0c7bd2b34e140a7a1b4af8f6/lib/grape/middleware/auth/dsl.rb#L15-L40","documentation":"The auth DSL (`auth`, `http_basic`, `http_digest`) takes keyword options. A positional Hash (e.g. `http_basic({ realm: 'x' }, &block)`) lands in the legacy splat; `merge_legacy_auth_options` warns via `Grape.deprecator`, merges it with the keyword options, and proceeds with the merged result.","triggerScenarios":"`auth :http_basic, { realm: 'API' }`; `http_basic({ realm: 'Restricted' }, &auth_block)`; `http_digest({ realm: 'api' }, &block)` — any auth call whose options Hash is passed as a positional argument.","commonSituations":"Older samples written before Ruby 3 keyword separation; gems that mount Grape APIs and build auth option hashes programmatically.","solutions":["Pass keywords: `auth :http_basic, realm: 'API'`","When options are dynamic, double-splat them: `auth(:http_digest, **opts, &block)`","Run the suite with `Grape.deprecator.behavior = :raise` to find stragglers"],"exampleFix":"# before\nhttp_basic({ realm: 'Restricted' }, &auth_block)\n\n# after\nhttp_basic realm: 'Restricted', &auth_block","handlingStrategy":"validation","validationCode":"# CI guard: auth DSL positional hashes raise in the test env\nGrape.deprecator.behavior = :raise if ENV['CI']","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass auth options as keywords: `http_basic realm: 'Restricted', &block`","When building auth calls dynamically, double-splat the options hash","Check mount gems for `auth :http_basic, {`-style calls when upgrading"],"tags":["grape","auth","deprecation","ruby3-keywords","dsl"],"backgroundTag":"deprecated-api-usage","analyzedSha":"22d7975629846a3c0c7bd2b34e140a7a1b4af8f6","analyzedAt":"2026-08-21T17:03:54.627Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}