{"id":"45e9f1cd1376ea6d","repo":"rails/rails","slug":"expected-name-to-be-a-string-got-name-class","errorCode":null,"errorMessage":"Expected name: to be a String, got #{name.class}","messagePattern":"Expected name: to be a String, got #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"actionpack/lib/action_controller/metal/http_authentication.rb","lineNumber":80,"sourceCode":"    #     def test_access_granted_from_xml\n    #       authorization = ActionController::HttpAuthentication::Basic.encode_credentials(users(:dhh).name, users(:dhh).password)\n    #\n    #       get \"/notes/1.xml\", headers: { 'HTTP_AUTHORIZATION' => authorization }\n    #\n    #       assert_equal 200, status\n    #     end\n    module Basic\n      extend self\n\n      module ControllerMethods\n        extend ActiveSupport::Concern\n\n        module ClassMethods\n          # Enables HTTP Basic authentication.\n          #\n          # See ActionController::HttpAuthentication::Basic for example usage.\n          def http_basic_authenticate_with(name:, password:, realm: nil, message: nil, content_type: nil, **options)\n            raise ArgumentError, \"Expected name: to be a String, got #{name.class}\" unless name.is_a?(String)\n            raise ArgumentError, \"Expected password: to be a String, got #{password.class}\" unless password.is_a?(String)\n            before_action(options) { http_basic_authenticate_or_request_with name: name, password: password, realm: realm, message: message, content_type: content_type }\n          end\n        end\n\n        def http_basic_authenticate_or_request_with(name:, password:, realm: nil, message: nil, content_type: nil)\n          authenticate_or_request_with_http_basic(realm, message, content_type) do |given_name, given_password|\n            # This comparison uses & so that it doesn't short circuit and uses\n            # `secure_compare` so that length information isn't leaked.\n            ActiveSupport::SecurityUtils.secure_compare(given_name.to_s, name) &\n              ActiveSupport::SecurityUtils.secure_compare(given_password.to_s, password)\n          end\n        end\n\n        def authenticate_or_request_with_http_basic(realm = nil, message = nil, content_type = nil, &login_procedure)\n          authenticate_with_http_basic(&login_procedure) || request_http_basic_authentication(realm || \"Application\", message, content_type)\n        end\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/rails/rails/blob/817fc2a147c249180ee9b271c0e8d82d43457a3a/actionpack/lib/action_controller/metal/http_authentication.rb#L62-L98","documentation":"Error \"Expected name: to be a String, got #{name.class}\" thrown in rails/rails.","triggerScenarios":"Thrown at actionpack/lib/action_controller/metal/http_authentication.rb:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"817fc2a147c249180ee9b271c0e8d82d43457a3a","analyzedAt":"2026-08-04T20:52:19.892Z","schemaVersion":2}