{"record":{"id":"da92ca14cb37a617","repo":"SeleniumHQ/selenium","slug":"page-size-must-be-a-symbol-or-a-hash","errorCode":null,"errorMessage":"Page size must be a Symbol or a Hash","messagePattern":"Page size must be a Symbol or a Hash","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/print_options.rb","lineNumber":88,"sourceCode":"          letter: {width: 21.59, height: 27.94},\n          legal: {width: 21.59, height: 35.56},\n          a4: {width: 21.0, height: 29.7},\n          tabloid: {width: 27.94, height: 43.18}\n        }\n\n        case value\n        when Symbol\n          raise ArgumentError, \"Invalid page size: #{value}\" unless predefined_sizes.key?(value)\n\n          @page_size = predefined_sizes[value]\n        when Hash\n          unless value.key?(:width) && value.key?(:height)\n            raise ArgumentError, 'Custom page size must include :width and :height'\n          end\n\n          @page_size = value\n        else\n          raise ArgumentError, 'Page size must be a Symbol or a Hash'\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":70,"sourceCodeEnd":94,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/print_options.rb#L70-L94","documentation":"page_size= only accepts a Symbol (predefined size) or a Hash (custom size). Any other type — String, Array, Integer, nil — raises ArgumentError. This is the catch-all branch of the case statement after the Symbol and Hash branches.","triggerScenarios":"Passing a String like page_size = 'A4'. Passing an Array [21, 29]. Passing an Integer or nil.","commonSituations":"Assuming a String size name is accepted. Providing a tuple/array from external data. Defaulting to nil accidentally.","solutions":["Use a predefined Symbol (:a4) or a Hash ({ width:, height: }).","Convert incoming data: if it is a String matching a known size, use .to_sym; otherwise build a Hash.","Avoid passing Arrays or Strings; map them to the supported types first."],"exampleFix":"# before\nprint_options.page_size = 'A4'\n\n# after\nprint_options.page_size = :a4","handlingStrategy":"type-guard","validationCode":"raise ArgumentError, 'page size must be Symbol or Hash' unless value.is_a?(Symbol) || value.is_a?(Hash)","typeGuard":"def valid_page_size?(value)\n  value.is_a?(Symbol) || value.is_a?(Hash)\nend","tryCatchPattern":"begin\n  print_options.page_size = value\nrescue ArgumentError => e\n  raise unless e.message.include?('Symbol or a Hash')\n  print_options.page_size = value.to_sym\nend","preventionTips":["Map Strings to Symbols (:a4) and Arrays/tuples to Hashes before assignment.","Reject nil unless you intend to keep the default.","Keep page-size data typed as Symbol or Hash throughout your config layer."],"tags":["ruby","print","page-size","type-error"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}