Mixed String and Symbol overrides send duplicate parameters
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 75/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- ruby
研究方向
閱讀lib/serpapi/client.rb,尤其是第64行的建構子和第290行的query,以及README中關於參數覆寫的承諾。先在執行bundle install後重現issue中的問題,接著檢查現有的query覆寫和圖片上傳spec。完成條件是:混用String和Symbol鍵時,每個參數只送出覆寫後的值,且測試涵蓋一般參數和上傳參數。
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- Ruby
- 星號
- 43
- 分支
- 27
- 平均合併
- 3 天 21 小時
- 30 天內合併 PR
- 5
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
serpapi/serpapi-ruby 的其他 Issue
-
Constructor symbolize_names defaults are ignored可能已有人在做 @yorzi 於 9 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
serpapi/serpapi-ruby#44 ·
查看 serpapi/serpapi-ruby 的全部 Issue
相似的 Issue
-
good first issue help wanted
難度 1/5 1 小時以內 新手友好度 90/100
erkamyaman/rust-anything#702 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
slovensko-digital/govbox-pro#986 ·
維護者通常 1 天內回覆
-
community
難度 2/5 1-3 小時 新手友好度 72/100
newrelic/newrelic-ruby-agent#3737 · 1 則留言 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆