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時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日以内に返信