Mixed String and Symbol overrides send duplicate parameters
@yorzi đang làm issue này rồi.
Từ ngày 17/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- ruby
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Đọc lib/serpapi/client.rb, đặc biệt là constructor ở dòng 64 và query ở dòng 290, cùng với cam kết trong README về việc ghi đè tham số. Bắt đầu bằng cách chạy cách tái hiện trong issue sau khi bundle install, rồi kiểm tra các spec hiện có về việc ghi đè query và tải ảnh lên. Hoàn thành khi các khóa String và Symbol kết hợp chỉ gửi giá trị ghi đè cho từng tham số, với các bài kiểm tra bao gồm cả tham số thông thường và tham số tải lên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Basic checks
- I searched existing issues, open and closed, and found no general mixed-key override fix
- I can reproduce this consistently on
master - This is a serpapi-ruby bug, not my application code
What's broken?
The constructor accepts String and Symbol keys
(lib/serpapi/client.rb:64), and README.md:88-117 promises that per-call
parameters override defaults. But query at client.rb:290 merges raw
Ruby Hash keys. If the call and default use different key types, both
reach HTTP.rb and are encoded with the same parameter name.
This affects engines, API-key overrides, nil overrides, and arbitrary
backend fields. It also affects image-upload form fields. A default that
should have been replaced is still sent. No particular server-side
precedence for duplicate parameters is assumed.
#29 already handles
this for output, and #37
handles Extract's forced engine. This report concerns ordinary overrides.
It does not include the Hash mutation in
#39 or error policy in
#42.
How to reproduce
From the repository root, after bundle install. HTTP.rb builds the real
request; perform is intercepted before network I/O:
bundle exec ruby -Ilib - <<'RUBY'
require 'serpapi'
response = Struct.new(:status, :headers, :body).new(
200, { 'Content-Type' => 'application/json' }, '{}'
)
transport = HTTP::Client.new
transport.define_singleton_method(:perform) do |request, _options|
p request.uri.query_values(Array).select { |key, _| key == 'engine' }
response
end
HTTP.define_singleton_method(:timeout) { |_timeout| transport }
client = SerpApi::Client.new('engine' => 'google', persistent: false)
client.search(engine: 'bing')
RUBY
Expected behavior
[["engine", "bing"]]
What actually happened
[["engine", "google"], ["engine", "bing"]]
I have a small local fix with tests and can open a PR.
Environment
- Ruby 3.4.4, macOS arm64
- serpapi-ruby
masterat786baa6848020df031abed734ed7ff03af3a6560 - HTTP.rb 5.3.1, RSpec 3.13.2
- No API credentials, external requests, or search credits used
- Ngôn ngữ chính
- Ruby
- Star
- 43
- Fork
- 27
- Merge trung bình
- 3 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của serpapi/serpapi-ruby
-
Constructor symbolize_names defaults are ignoredCó thể đã có người làm @yorzi đã nhận 9 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
serpapi/serpapi-ruby#44 ·
Tất cả issue của serpapi/serpapi-ruby
Issue tương tự
-
good first issue help wanted
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
erkamyaman/rust-anything#702 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
slovensko-digital/govbox-pro#986 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
community
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
newrelic/newrelic-ruby-agent#3737 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày